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 microkernel architecture. Microkernel 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 Microkernel and Monolithic kernel -
A Monolithic kernel is an OS architecture where the entire operating system is working in kernel space. But unlike microkernel, 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 runtime. 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 Microkernel architecture, the core functionality is isolated from system services and device drivers. Microkernel being a kernel manages all system resources. But in a microkernel, 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 microkernel 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 microkernel.
In short, if its a module in Linux, its a service in a microkernel, indicating an isolated process. In a microkernel, 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 microkernel. The microkernel 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 microkernel 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 Microkernel, the idea was conceived at the end of the 1980s.
In Monolithic kernels, the device drivers reside in the kernel space while in the Microkernel the device drivers reside in the user space.
Since the device driver resides in the kernel space, it makes monolithic kernel less secure than microkernel, and failure in the driver may lead to a crash. Microkernels are more secure than the monolithic kernel, hence used in some military devices.
Monolithic kernels are used in Unix and Linux. Microkernels 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 microkernels you can add new features or patches without recompiling.
Monolithic kernels are faster than microkernels. The first microkernel 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 Microkernel has to be small in size, to fit into the processor's L1 cache.
Monolithic kernels use signals and sockets to ensure IPC, microkernel approach uses message queues. 1st gen microkernels 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 Microkernel is small and isolated hence it can function better.
To write a microkernel, more code is required. On the other hand, to write a monolithic kernel, less code is required.