What is a kernel

What is a Kernel?

A kernel is the core of any operating system. It handles absolutely everything that happens in your computer and it is the first program that runs when your computer is turned on. It handles your computer's memory, hardware, processes, program execution, security (for example if someone tries to write to read-only memory, the kernel stops it), filesystems , system calls, it allows you to connect to the internet and many other things. In other words it handles almost every function of an OS, and if you want an even simpler definition, we can say it is the most important program in any computer because of it handling almost every action in the computer. Although the kernel is the most important part in any computer, we do not directly interact with it, we actually never even see it. We cannot choose when to start it or when to shut it off, this is where the OS comes in.

What is an Operating System (OS)?

Now that we know what a kernel is, we can proceed to define what an operating system is. As you already know the kernel handles every function in a computer, but in order to use a computer we also need of other things (we cannot use the kernel just like that) such as programs. An operating system is made of 2 basic components: the Kernel and a Userspace. The Userspace is made of many components:

  • Programs: This are system utilities that are needed in order to use the operating system (like a shell or GNU Binutils).
  • Applications: This are programs that are not necessary in order to run the system, they just add extra functionality for the user.
  • Standard C Library: We will define this later.

So we could say that the OS is the medium we use in order to communicate with our computer and in order to tell it what to do. Every computer has one and it is the first thing we see when we boot up our computer and it is what allows us to tell the kernel what to do. Although it may seem program execution or using the keyboard is the work of the OS, it is actually the job of the kernel. The OS is built on top of the kernel and it is basically the application and program layer of the kernel.

Kinds of Kernels

There are 2 main different kernel models, what differentiates them is the way they work, they load drivers, they handle kernel services, etc... The 2 main kinds of kernels are Monolithic and Microkernel.

Monolithic Kernel

A monolithic kernel is the one that most of it's services are kernel services (they run in the kernel proper). Because of this the amount of context switching and messaging is reduced, also there is no need to load external modules in User Mode, making it faster than a microkernel. But in the other hand there is a lot of code running in kernel mode, making it more propense to fatal bugs than any other kernel models. This kernel is usually a single binary and comes in a single piece. Examples of this kind of kernel are: Linux, Windows (95, 98, Me), BSD, macOS (Darwin) ≥ 8.6.

monolithic kernel model

Microkernel

A microkernel is almost the opposite of a Monolithic kernel. It tries to run only the most basic functions like memory allocation (not management), scheduling and messaging while loading everything else (filesystem, drivers, networking, etc...) as a daemon (server) in the Userspace. This makes the kernel more responsive since the great majority of services and functionality is run under the Userspace, the kernel is usually more stable and less prone to bugs as well since there is much less code running in the Kernel space. But because of it having more context switches and more messaging in comparison to a Monolithic Kernel, it is theoretically slower than a Monolithic Kernel, but still a smartly designed Microkernel can beat a Monolithic Kernel in speed. Another problem with this kind of kernels is that since must of the functionality is under Userspace, if a daemon crashes the kernel keeps running. And if something important such as a filesystem driver crashes, the kernel will still be running resulting in possible data loss. In order to prevent this Microkernels must have a way to restart the filesystem daemon and have some memory recovery system when this happens. Examples of this kinds of kernel are: Mach, Minix, AmigaOS, L4 and QNX.

microkernel model

Hybrid Kernel

As the name may indicate, an hybrid kernel is a hybrid of a Monolithic Kernel and a Microkernel. The kernel designer may choose to keep some functions inside the kernel space although he may choose to keep others outside the kernel space. A Hybrid kernel may start as a Monolithic Kernel that moves some drivers to the Userspace as programs. One possible reason for the kernel designer to do this may be to add compatibility to third party drivers, and it can be used also as a security measure to prevent malicious ones of harming the system. Other reason a kernel designer might do this is to improve the stability or speed of its kernel. But still the same problem that exists in Microkernels might arise if the filesystem or other drivers are placed in the Userspace, so other measures should be taken in order to prevent data loss. Examples of this kind of kernel are Windows NT and above, macOS (xnu), Haiku, ReactOS, DragonFly BSD, among others.

results for ""

    No results matching ""