The kernel is the central component of a computer operating systems. The only job performed by the kernel is to the manage the communication between the software and the hardware. A Kernel is at the nucleus of a computer. It makes the communication between the hardware and software possible. While the Kernel is the innermost part of an operating system, a shell is the outermost one.
Features of Kennel- Low-level scheduling of
processes
- Inter-process communication
- Process synchronization
- Context switching
Types of Kernels
There are many types
of kernels that exists, but among them, the three most popular kernels are:
Re-entrant kernel:
A re-entrant kernel
enables a process (and its threads) to give away the CPU while in kernel mode.
They do not hinder other processes from also entering kernel mode. This
behavior allows CPU to be shared among multiple processes.
A typical use case is
IO wait. The process wants to read a file. It calls a kernel function for this.
Inside the kernel function, the disk controller is asked for the data. Getting
the data will take some time and the function is blocked during that time.
With a re-entrant kernel, the scheduler will assign the CPU to
another process (kernel thread) until an interrupt from the disk controller
indicates that the data is available and our thread can be resumed. This
process can still access IO (which needs kernel functions), like user input.
The system stays responsive and CPU time waste due to IO wait is reduced.
All Unix kernels are
reentrant. This means that several processes may be executing in Kernel Mode at
the same time. Of course, on uniprocessor systems, only one process can
progress, but many can be blocked in Kernel Mode when waiting for the CPU or
the completion of some I/O operation.
If a hardware
interrupt occurs, a reentrant kernel is able to suspend the current running
process even if that process is in Kernel Mode. This capability is very
important, because it improves the throughput of the device controllers that
issue interrupts.
Ex: The Linux kernel
Version 2.6 (which was introduced in late 2003) is preemptive. That is, a
process running in kernel mode can be suspended in order to run a different
process. This can be an important benefit for real time applications (i.e.,
systems which must respond to external events nearly simultaneously). Unix-like
kernels are also re-entrant, which means that several processes can be in
kernel mode simultaneously. However, on a single-processor system, only one
process, regardless of its mode, will be progressing in the CPU at any point in
time, and the others will be temporarily blocked until their turns.
Monolithic
Monolithic Kernel runs
all the basic system services like process management, Memory management, I/O
communication, and interrupt handling, file system, etc in kernel space.
- One of the major advantages of having monolithic kernel is that it provides CPU scheduling, memory management, file management and other operating system functions through system calls.
- The other one is that it is a single large process running entirely in a single address space.
- It is a single static binary file. Example of some Monolithic Kernel based OSs are: Unix, Linux, Open VMS, XTS-400, z/TPF.
Disadvantages of Monolithic Kernel –
- One of the major disadvantages of monolithic kernel is that, if anyone service fails it leads to entire system failure.
- If user has to add any new service. User needs to modify entire operating system.
Microkernel is a
software or code which contains the required minimum amount of functions, data,
and features to implement an operating system. It provides a minimal number of
mechanisms, which is good enough to run the most basic functions of an
operating system. It allows other parts of the operating system to be
implemented as it does not impose a lot of policies.
- Microkernel architecture is small and isolated therefore it can function better.
- Microkernels are secure because only those components are included that disrupt the functionality of the system otherwise.
- The expansion of the system is more accessible, so it can be added to the system application without disturbing the Kernel.
- Microkernels are modular, and the different modules can be replaced, reloaded, modified without even touching the Kernel.
- Fewer system crashes when compared with monolithic systems.
- Microkernel interface helps you to enforce a more modular system structure.
- Without recompiling, add new features
- Server malfunction is also isolated as any other user program's malfunction.
- Microkernel system is flexible, so different strategies and APIs, implemented by different servers, which can coexist in the system.
- Increased security and stability will result in a decreased amount of code which runs on kernel mode
Disadvantage of Microkernel
- Providing services in a microkernel system are expensive compared to the normal monolithic system.
- Context switch or a function call needed when the drivers are implemented as procedures or processes, respectively.
- The performance of a microkernel system can be indifferent and may lead to some problems.
USER Mode
If CPU is executing the user applications then CPU will be in the user mode. The User applications are games, media players, text editor, MS Office etc.
Executing code in user mode has no ability to directly access some resources like Hard Disk, memory, Printer and other I/O devices. Because, To access these resources we have to use kernel mode through System Call.
Note: User mode is also known as safe mode and Restricted mode.
Kernel Mode
Kernel mode contains OS which has full functionality to access and maintain all the hardware components. Hardware components are RAM, HARD, CPU, printer and other I/O devices.
Whenever the system call generate, CPU switch to kernel mode from user mode. System call is executed in kernel mode. After execution of system call it returns back to user mode.
Note: kernel mode also known as system, privileged (private) or supervisory mode, protected mode because user can’t access this area directly
0 Comments