Image source wikipedia

Kernel

What is Kernel?

The kernel is a common term in computing. A kernel is a computer program that exists as the core of an Operating system. A kernel is a program at the center of an OS that controls all the basic functions and distributes hardware allocations for other programs and subprograms. A kernel is the base of an OS, and as such, it controls every aspect of the computer’s hardware. The kernel is the first program that is loaded when a computer starts up immediately after the bootloader. No other programs can run before the kernel. Once it is loaded up, the kernel remains in the system’s volatile memory until a shutdown occurs.

The kernel program handles all the base-level tasks on the computer like disk management, memory management, task management, etc. It acts as a bridge between the visible OS (the user interface) and the hardware components. Any process that connects to the kernel is called a “system call” in technical terms. A segment of the computer’s memory is always allocated to the kernel. This space is called the kernel space and is completely off-limits to other programs and processes. The kernel code is always loaded into this protected Kernel Space on start-up. The remaining part of the memory is called the user space and is dedicated to performing secondary tasks associated with the kernel. These two segments of the computer’s memory are separate, and as such, interactions between them are slower.

Functions of Kernel

A kernel controls all the basic OS functions and has a wide range of singular uses. However, these uses are put into 3 main categories.

Resource management

Kernels play key roles in the management of a computer’s resources. They help define execution domains and control the protection mechanism that oversees the resources within the said domain. Kernels also aid synchronization and inter-process communication (IPC). These IPCs can be inside the kernel itself or alongside other processes. Kernels are also essential to context switching between processes or threads.

Memory management

The kernel holds the keys to the computer’s memory and, as such, governs how much memory other processes will use. The kernel decides when to allocate memory to a process and when to deallocate from finishing processes.

Device management

Processes require access to some of the computer’s peripherals. These peripheral devices are not imbued in the OS and, as such, have to be configured to be used by third-party programs. The kernel handles this installation and configuration through the device drivers.

Types of Kernel

Kernels exist in every OS and come in five major forms. The first two on this list are the major ones and are sometimes considered the only kernel types. This list has a broader view than that and encompasses the five main types.

  1. Monolithic Kernels

Monolithic Kernels exist on the same memory as the userspace. This means that the Kernel space of monolithic kernels and the space for user services are implemented in the same memory space. There are no separate memory modules for each space. This type of kernel has an increased size on the memory, and as such, monolithic kernels exist in bigger Operating systems. With the user space and kernel space on the same module, the interactions between them will be faster, i.e., processes are faster on monolithic kernels. Monolithic kernels provide CPU scheduling, memory scheduling, file management through System calls only. However, joint memory usage means that it can cause a system-wide crash if a single process fails. Monolithic kernels needed their entire Operating systems modified if any new service is to be added.

  1. Microkernel

A microkernel is the second major group of kernels and is basically the direct opposite of monolithic kernels. A microkernel has its userspace on a separate memory space from the kernel, i.e., the kernel space and the user space exist on two different memory spaces. This separation causes the kernel to be smaller than its monolithic counterparts, and as such, it has a smaller OS than monolithic kernels. The separate memory spaces require a different form of communication. Microkernels use a message parsing system to communicate between the user and kernel spaces, and this makes the speed of execution slower than monolithic kernels. The speed reduction has a silver lining because new services can be easily added to microkernels without all the ceremony of monolithic kernels. Unfortunately, the reduced execution speed sometimes out shadows the positives.

  1. Hybrid Kernel

A hybrid kernel, as the name suggests, is a combination of both monolithic and microkernels. It takes the best of both worlds as it has the speed of a monolithic kernel while keeping the modularity of microkernels. Hybrid kernels have a microkernel base but include some “non-essential” code in kernel-space for the code to run more quickly than it would be in user-space. This code makes some services like network and filesystem run in the kernel source to make the computer perform just as fast as possible if it had a monolithic kernel.

  1. Nanokernel

A nano kernel is a simple kernel that is, as its name suggests, extremely small. The code is minimal, and it is named after the fact that it supports a nanosecond clock resolution.

  1. Exokernel

Exokernel is a kernel that was recently developed by the MIT parallel and the Distributed Operating Systems group. This kernel separates its resource protection from resource management. This separation allows users to perform customized application processes.