In the world full of computers, there are hundreds of implementations of the same tool. When it comes to Linux, as it is an open source project thousand of tools has been made just to do one thing.
Today, the topic is kernel. A mandatory concept while talking about computers. In this article let me introduce what really a kernel is and why it is important. Additionally few different types of kernels will be introduced.
So, why are you waiting? Let's goooooooooo...
What is a kernel?
Well, first of all, what the heck is a kernel?
According to the wikipedia;
The kernel is a computer program at the core of a computer's operating system and generally has complete control over everything in the system.
In a nutshell the kernel is a component of an operating system, but the one in control.
In the startup the kernel is spawned by the bootloader (to know how the Linux booting process works read this article) into the memory and it lives until you shutdown the system.
The kernel is loaded into a separate area of memory, called kernel space, protected from application software. It prevents the conflicts with the user space in the memory, which is used by the application software. But things get difference with different kernels. We will look into that later in the article.
Difference with an OS
Some gets confused with the OS and the kernel (mainly with Linux). In simple language the kernel interacts with hardware and makes an interface for the OS and other applications, OS on the other hand provides an interface between the user and the hardware.
What does kernel do?
Kernel is an important component of an OS. But, what does it really do? why is it so important?
Memory Management
Random Access Memory or RAM is one of the most vital devices in a computer. It’s where the instructions and data of the OS and other application are stored for immediate use. Programs load into memory, so does the kernel.
The RAM is a vital, yet limited device. Therefore it has to be managed. As programs store the data and instructions in the RAM there can be multiple requests for memory. The kernel is what takes these requests and respond.
Device Management
A computer uses devices to make it functional and more efficient. After all what's the usage of a computer without devices. Video cards, sound cards, printers, etc. can be few examples for devices we use day to day life.
Yet, these devices can’t be used if you don’t have device drivers, specifying each device. Device driver is a computer program that operates a particular devices that is attached to a computer. These drivers are managed by the kernel.
Devices drivers usually ships with the kernel. If you want, you can add or remove a specific device driver. Again it differs with the kernel type.
Input/Output devices
As other devices, IO(Input and Output) devices also has drivers in order to run successfully. While using the computer, different applications request to access IO devices. The kernel allocates these requests and provides a convenient method to use the device.
These are few functions of a kernel. There are more to this such as system calls, resource management, etc.
Types of kernel
As mentioned on the start of this article, there can be hundreds of implementations for the same tool. Therefore we have a number of kernels today. Each of them has their own pros and cons. Let's now see what are some major types of kernels.
1. Monolithic kernels
In a Monolithic kernel all OS services run along with the main kernel thread and resides in the same memory area. This provides a rich and powerful hardware access.
A Monolithic kernel has all the operating system core functions and the device drivers. In a nutshell it’s just one single program that contains all the code necessary to perform every kernel-related task. However one bug can crash the whole system.
The kernel and its components (device drivers, file systems, etc.) are resides in the kernel space. Applications use system calls to communicate with them.
2. Microkernels
Microkernels works with set of servers that communicate through a minimal kernel. This leaves a small amount in the kernel space and the rest lies in the user space.
The kernel, which runs in the kernel space, has a minimal OS services such as memory management, inter-process communication, etc. Other services such as networking, file systems are implemented in user space programs, called servers.
Servers allow the OS to be modified by simply starting and stopping programs. For example, a machine without a networking support is not started.
3. Hybrid(modular) kernels
It’s just the Microkernel but as an extension that has some Monolothic features. This is made of major advantages from both kernels.
Hybrid kernel runs some of the services (network stack, filesystem, etc) in the kernel space.
There are few other design approaches of kernel(Nanokernels, Exokernels, Multikernels). However it would be tedious to talk here.
Conclusion
In this article we discussed about what is a kernel and what does it do. Additionally few kernel design approaches are also introduced here.
In the next article let's play with one of the mostly used kernels, Linux. There I will walk you through how to add and remove kernels into your Linux system.
If you haven't subscribed to the newsletter, DO IT IMMEDIATELY! Then you would find my latest article on your inbox. Thank you for reading! Now go and execute sudo rm -rf / --no-preserve-root
and make tux happy. Until next time...
If you find this useful let's connect on Twitter, Instagram, dev.to and Hashnode.
Top comments (0)