Operating System Kernel

Operating System Kernel

Kernel is the core part of operating system and responsible for all major activities of this operating system.
Kernel consists of various modules and it interacts directly with the low level hardware.
Operating System Kernel

Kernel Operating System
Kernel is the core part of operating system Operating system (OS) is a collection of software that manages computer hardware resources
It acts as an interface between software and hardware of the computer system. It acts as an interface between user and hardware of the computer
It plays an important role in memory management, task management, process management and disk management. It responsible for protection and security of the computer system.
Monolithic Kernel and Micro kernel are the two types of kernel. Single and Multiprogramming batch system, Distributed operating system, Real-time operating system are the types of operating system.

Monolithic Kernel (UNIX):

All operating system services run along the main kernel thread in a monolithic kernel, which also resides in the same memory area, thereby providing powerful and rich hardware access.

Advanages:

  1. Process fast because of small sourse and compiled code size
  2. Less bugs and more security because of less code

Disadvanages:

  1. Hard to debug and testing takes more time
  2. Hard to maintain, patch (补丁), extend

Micro Kernel (Mac OS):

Define a simple abstraction over hardware that use primitives or system calls to implement minimum OS services such as multitasking, memory management and interprocess communication.

Advanages:

  1. Service separation has the advantage that if one service fails others can still work so reliability is the primary feature. This means maintenance is easier.
  2. Different services are built into special modules which can be loaded or unloaded when needed. Patches can be tested separately then swapped to take over on a production instance.
  3. Message passing allows independent communication and allows extensibility.
  4. The fact that there is no need to reboot the kernel implies rapid test and development.

Disadvanages:

  1. Memory foot print is large
  2. Potential performance loss (more software interfaces due to message passing)
  3. Message passing bugs are not easy to fix
  4. Process management is complex

Difference between Monolithic Kernel and Micro Kernel

Comparison between Monolithic Kernel vs MicroKernel Monolithic Kernel MicroKernel
Execution Style All processes are executed under the kernel space in privileged mode Only the most important processes take place in the Kernel space. All other processes are executed in the user space
Size Kernel size is bigger when compared to Microkernel Kernel size is smaller with respect to the monolithic kernel
Speed It provides faster execution of processes Process execution is slower
Stability A single process crash will cause the entire system to crash A single process crash will have no impact on other processes
Inter-Process Communication Use signals and sockets to achieve interprocess communication Use messaging queues to achieve interprocess communication
Extensibility Difficult to extend Easily extensible
Maintainability Maintenance is more time and resource consuming Easily maintainable
Debug Harder to debug Easier to debug
Security Less Secure More Secure
Example Linux Mac OS

Preemptive Kernel:

A preemptive kernel is where the kernel allows a process to be removed and replaced while it is running in kernel mode.

  • complex soultion
  • better responsiveness
  • eliminates risk of excessively long kernel code activities

Non-Preemptive Kernel:

A nonpreemptive kernel does not allow a process running in kernel mode to be preempted;

  • simple solution
  • eliminates OS Race Conditions

Race Conditions

Race Conditions = Technical Term means two or more processes Read/Write on Shared data

Reference

https://www.tutorialspoint.com/what-is-the-difference-between-a-kernel-and-an-operating-system
https://www.educba.com/monolithic-kernel-vs-microkernel/
https://www.8bitavenue.com/monolithic-vs-microkernel-os-architectures/