Module 5 Notes
Module 5 Notes
User
Applications Application Program
Memory Management Interface(API)
Process Management
Time Management
File System Management
I/O System Management
Process Management:
Process management deals with managing the processes/tasks.
The kernel maintains a list of all the I/O devices of the system.
o May be available in advance or updated dynamically as and
when a new device is installed.
The service Device Manager of the kernel is responsible for handling
all I/O device related operations.
The kernel talks to the I/O device through a set of low-level systems
calls, which are implemented in a service called device drivers.
Protection Systems:
Most of the modern operating systems are designed in such a way to
support multiple users with different levels of access permissions.
o E.g. ‘Administrator’, ‘Standard’, ‘Restricted’ permissions in
Windows XP.
o User applications
o Kernel applications
• User Space is the memory area where user applications are loaded
and executed.
dependent.
o Some OS implement this kind of partitioning and
protection
whereas some OS do not segregate the kernel and user
application code storage into two separate areas.
Monolithic Kernel:
In monolithic kernel architecture, all kernel services run in the kernel
space.
Here all kernel modules run within the same memory space under a
single kernel thread.
The tight internal integration of kernel modules in monolithic kernel
architecture allows the effective utilisation of the low-level features of
the underlying system.
The major drawback of monolithic kernel is that any error or failure in
any one of the kernel modules leads to the crashing of the entire kernel
application.
LINUX, SOLARIS, MS-DOS kernels are examples of monolithic
kernel.
The architecture representation of a monolithic kernel is given in the
figure.
Applications
Microkernel:
• The microkernel design incorporates only the essential set of
Operating System services into the kernel.
examples of errors/exceptions.
Errors/Exceptions can happen at the kernel level services or at
task level.
Deadlock is an example for kernel level exception, whereas
timeout is an example for a task level exception.
The OS kernel gives the information about the error in the form
of a system call (API).
Watchdog timer is a mechanism for handling the timeouts for
tasks.
5. Memory Management:
RTOS makes use of 'block' based memory allocation technique,
instead of the usual dynamic memory allocation techniques
used by the GPOS.
RTOS kernel uses blocks of fixed size of dynamic memory and
the block is allocated for a task on a need basis.
The blocks are stored in a 'Free Buffer Queue’.
To achieve predictable timing and avoid the timing overheads,
most of the RTOS kernels allow tasks to access any of the
memory blocks without any memory protection.
RTOS kernels assume that the whole design is proven correct
and protection is unnecessary.
Some commercial RTOS kernels allow memory protection as
optional.
A few RTOS kernels implement Virtual Memory concept for
memory allocation if the system supports secondary memory
storage (like HDD and FLASH memory).
In the 'block' based memory allocation, a block of fixed
memory is always allocated for tasks on need basis and it is
taken as a unit.
Hence, there will not be any memory fragmentation issues.
The 'block' based memory allocation achieves deterministic
behavior with the trade of limited choice of memory chunk size
and suboptimal memory usage.
6. Interrupt Handling
Synchronous interrupts:
Occur in sync with the currently executing task.
Usually the software interrupts fall under this category.
Divide by zero, memory segmentation error, etc. are examples of
synchronous interrupts.
For synchronous interrupts, the interrupt handler runs in the
same context of the interrupting task.
Asynchronous interrupts:
o Occur at any point of execution of any task, and are not in
sync with the currently executing task.
o The interrupts generated by external devices (by asserting
the interrupt line of the processor/controller to which the
interrupt line of the device is connected) connected to the
processor/controller, timer overflow interrupts, serial data
reception/ transmission interrupts, etc. are examples for
asynchronous interrupts.
o For asynchronous interrupts, the interrupt handler is
usually written as separate task and it runs in a different
context.
o Hence, a context switch happens while handling the
asynchronous interrupts.
Priority levels can be assigned to the interrupts and each
interrupt can be enabled or disabled individually.
Most of the RTOS kernel implements 'Nested Interrupts'
architecture.
o Interrupt nesting allows the pre-emption (interruption)
of an Interrupt Service Routine (ISR), servicing an
interrupt, by a high priority interrupt.
7.Time Management:
Accurate time management is essential for providing precise
time reference for all applications.
The time reference to kernel is provided by a high-resolution
Real-Time Clock (RTC) hardware chip (hardware timer).
The hardware timer is programmed to interrupt the
processor/controller at a fixed rate.
This timer interrupt is referred as ‘Timer tick’ and is taken as the
timing reference by the kernel.
The 'Timer tick' interval may vary depending on the hardware
timer.
Usually the 'Timer tick' varies in the microseconds range.
The time parameters for tasks are expressed as the multiples of
the ‘Timer tick'.
The System time is updated based on the 'Timer tick’.
If the System time register is 32 bits wide and the 'Timer tick'
interval is 1 microsecond, the System time register will reset in
If the ‘Timer tick' interval is 1 millisecond, the system time
register will resent in
The 'Timer tick' interrupt is handled by the 'Timer Interrupt'
handler of kernel.
The 'Timer tick' interrupt can be utilised for implementing the
following actions:
Save the current context (Context of the currently executing
task).
Increment the System time register by one. Generate timing
error and reset the System time register if the timer tick count is
greater than the maximum range available for System time
register.
Update the timers implemented in kernel (Increment or
decrement the timer registers for each timer depending on the
count direction setting for each register. Increment registers with
count direction setting = 'count up' and decrement registers with
count direction setting = 'count down').
Activate the periodic tasks, which are in the idle state.
Invoke the scheduler and schedule the tasks again based on the
scheduling algorithm.
Delete all the terminated tasks and their associated data
structures (TCBs).
Load the context for the first task in the ready queue. Due to
the re-scheduling, the ready task might be changed to a new
one from the task, which was preempted by the 'Timer
Interrupt'