Thu Apr 07 2022
Difference between Monolithic and Micro Kernel
Kernel is the heart of an operating system. It manages the system resources. Kernel is like a bridge between application and hardware of the computer. However, there are different design principles governing developing of a kernel.
On the one end of the spectrum, there is the Monolithic kernel architecture and at the other end is the micro kernel architecture. Micro kernel is the one in which user services and kernel services are kept in separate address space. However, in Monolithic kernel user services and kernel services both are kept in the same address space.
Let discuss more about Micro kernel and Monolithic kernel -
A Monolithic kernel is an OS architecture where the entire operating system is working in kernel space. But unlike micro kernel, the user services and kernel services are implemented under same address space. This increases the size of the kernel further increases the size of operating system.
Monolithic kernels are able to dynamically load executable modules at run-time. It manages the system resources between application and hardware of the system. The monolithic kernel provides CPU scheduling, memory management, file management, and other operating system functions through system calls. As user services and kernel services both reside in same address space, this results in the fast executing operating system.
One of the drawbacks of the monolithic kernel is if anyone service fails entire system is crashed. If a new service is to be added in a monolithic kernel, the entire operating system is to be modified.
Examples - Linux, FreeBSD, OpenBSD, NetBSD, Solaris, OS-9, AIX, HP-UX, DOS, Microsoft Windows (95,98,Me), OpenVMS, XTS-400 etc.
Whereas in a Micro kernel architecture, the core functionality is isolated from system services and device drivers. Micro kernel being a kernel manages all system resources. But in a micro kernel, the user services and the kernel services are implemented in different address space. The user services are kept in user address space, and kernel services are kept under kernel address space. This reduces the size of the kernel and further reduces the size of the operating system.
In addition to the communication between application and hardware of the system, the micro kernel provides minimal services of process and memory management. The communication between the client application and services running in user address space is established through message passing. They never interact directly. This reduces the speed of execution of micro kernel.
In short, if its a module in Linux, its a service in a micro kernel, indicating an isolated process. In a micro kernel, the user services are isolated from kernel services so if any user service fails it does not affect the kernel service and hence Operating system remain unaffected. This is one of the advantages in the micro kernel. The micro kernel is easily extendable. If the new services are to be added, they are added to user address space and hence, the kernel space does not require any modification. The micro kernel is also easily portable, secure and reliable.
Examples - QNX, Integrity, PikeOS, Symbian, L4Linux, Singularity, K42, Mac OS X, HURD, Minix, and Coyotos.
Monolithic vs Micro Kernel
A monolithic kernel is much older than Micro kernel, the idea was conceived at the end of the 1980s.
In Monolithic kernels, the device drivers reside in the kernel space while in the Micro kernel the device drivers reside in the user space.
Since the device driver resides in the kernel space, it makes monolithic kernel less secure than micro kernel, and failure in the driver may lead to a crash. Micro kernels are more secure than the monolithic kernel, hence used in some military devices.
Monolithic kernels are used in Unix and Linux. Micro kernels are used in QNX, L4, and HURD. It was initially used in Mach (not Mac OS X) but later converted into a hybrid kernel. Even Minix is not a pure kernel because device drivers are compiled as part of the kernel.
Adding a new feature to a monolithic system means recompiling the whole kernel, whereas with micro kernels you can add new features or patches without recompiling.
Monolithic kernels are faster than micro kernels. The first micro kernel Mach was much slower than Monolithic kernel, while later version like L4 was only 2% or 4% slower than the Monolithic kernel.
Monolithic kernels generally are bulky. A pure Micro kernel has to be small in size, to fit into the processor's L1 cache.
Monolithic kernels use signals and sockets to ensure IPC, micro kernel approach uses message queues. 1st gen micro kernels poorly implemented IPC so were slow on context switches.
One of the major disadvantages of the monolithic kernel is that if anyone service fails it leads to entire system failure.
The architecture of Micro kernel is small and isolated hence it can function better.
To write a micro kernel, more code is required. On the other hand, to write a monolithic kernel, less code is required.