What is the function of the kernel of an operating system?

Don’t know what is the function of the kernel of an operating system? Do you know what types of kernels you have on your system? Learn everything you need to know about the kernel there is. See what are the different types of kernels there are and how they differ from each other.

In the article, we are going to learn about the kernel and what it is used for. Go through the sections one after another or else you can get confused mid-way. We will be discussing some examples to understand the Kerner better and understand its functionality.

What is the function of the kernel of an operating system?

What is Kernel?

We can understand the kernel as a computer program which is the most important thing for an Operating System like the heart in our body. And since you know that the Operating System is responsible for controlling your entire PC or laptop. So the kernel is indirectly controlling everything on your PC or laptop, hope this was clear. So now you must understand the importance of the kernel on your system (PC).

Another thing you should keep in mind is that the kernel is the first thing to run after the bootloader. And if you remember from our other articles, the bootloader is the first thing to run once you power on your PC. Now the bootloader handles everything on your system once the bootloader has done its work. The kernel stays in the memory until you power off your PC and the Operating System turns off.

Now we will be looking at a more technical definition of the Kernel, so if you are not interested then skip this part. The kernel is mainly responsible for low-level tasks management, such as task management, disk management & memory management. The kernel is responsible for providing an interface between hardware and user. Whenever the system process is requesting the kernel, it’s called a System Call.

All of the kernel code is stored in a Kernal space which is protected. This means that you can not temper with the kernel even if you had access to the Operating system. This is a very critical requirement since many important functions are performed by the kernel. So the kernel is loaded into the protected memory where it can not be changed in any way.

Now in the other space (memory space), the user data is stored, where the data of applications you are using is stored. This memory space is known as User Space. These two memory sections communicate with each other to run your operating system. However, the communication is relatively slow since both are two different memory sections.

What does Kernel do?

Now once we know about what a kernel is, in this section, we will see what the kernel does.

The kernel is responsible for communication between hardware and software which enables us to use our PCs. It uses drivers to communicate with the hardware since the kernel is software. You must be familiar with the driver since you are required to download new hardware. For example, if you buy a new Graphics card, printer or printer. Then you will be required to download a driver which may come in a CD or website link. This driver enables your kernel or OS to talk with that hardware.

We can take another example to understand it better, you can skip this part if you want. Whenever you are watching a movie, the media player is sending audio to the OS. Then the OS with the help of the kernel sends a request to the speaker to play that audio. Now to send that request we need a driver to communicate (understand what hardware) with the speaker.

Other tasks of Kernel

We have seen that is the main work or task of the kernel without which you will not be able to use your PC. Now we will see other tasks which are done by the kernel.

Now the kernel is also responsible for handling resource management on your system. Whenever you open the task manager, you will see memory and RAM usage by each app. It handles the resource distribution and redistribution after you close an app.

Once you close any app, the resources occupied by it will be free and unused. The kernel then reassigns the resources so your system will work optimally.

Along with it, the kernel also performs internal tasks to optimize the usage of the processor. If you are familiar with the term “deadlock” then the kernel will prevent it from happening. But if you don’t know then know that deadlock is a condition in which 2 or more apps want the same resource. And none of them is backing up, which pauses those apps and the app becomes “unresponsive”. You can understand it like a road being blocked because of two drivers who both refuse to reverse in a single-lane road.

Function of a Kernel on operating system

Now we will be discussing the functions of the kernel in-depth, you already understand the basics. So if you are not interested in the detailed functions of the kernel then you can skip this whole section. The following are the standard functions that are performed by the kernel on operating your system:

  1. Memory Management: We have already discussed memory management but we will see more technical functions. The kernel is responsible for allocating and deallocating memory to system and user applications. This memory is important for the execution of tasks in those applications. The kernel is responsible for the memory management of your system and without it, you will not be able to get any work done.
  1. Accessing Resources: Kernel manages the resources such as I/O devices, CPU usage, and other important resources. Along with management, it also acts as a bridge between system resources and the user.
  1. Device Management: We have seen how the kernel performs device management with the example of GPU, printer. Any peripheral device you connect with your system, the kernel is managing them. You can even see the list of devices connected with your system Right-click “This PC” -> Manage -> Device management.
  1. Resource Management: You must be familiar with the fact that the kernel performs resource management, as discussed in the previous section. Kernel shares the resources between all the applications running on your system. This way your system keeps running in the optimal state without any resource sitting idle.

What is Kernel Mode?

The CPU needs to perform all sorts of tasks and each task requires either kernel or user mode. In the user mode, the CPU can not perform the majority of the system tasks which are required to run your system. And the CPU does not need to be in the kernel mode to run the application which you are trying to run. So the CPU bounces between these two modes to manage different types of tasks. All the critical system tasks or instructions need to run in kernel mode.

For example, as we saw earlier that memory management is done by the kernel only. This is why the CPU needs to be in the kernel-mode while it’s performing memory management. On the other hand, the CPU is in user mode when you give some process or task.

Types of Kernel

We will be seeing all the different types of kernels which are present in your system. There are mainly 5 types of kernels and we will be seeing in-depth about them.

Monolithic Kernel

In these types of kernels, there is no separate user space and kernel space. This is because the kernel is implemented in the same memory space. This means that the kernel uses the same memory for kernel services and user services. Due to this shared memory, the size of the OS increases because the size of the kernel is increased. The added benefit of the common memory space is that the execution is faster compared to other kernels.

MicroKernel

In these types of kernels, unlike the monolithic kernel, both the services (user & kernel) are not implemented in the same memory space. Or we can say that kernel services and user services are not implemented in the same memory space. This reduces the size of the OS because the size of the kernel is reduced. However, the execution is slower compared to the monolithic kernel since there are different memory spaces. So the communication between both the memory spaces is done with the help of message parsing which makes execution slower.

Hybrid Kernel

These types of kernels are as the name suggests a combination (hybrid) of Monolithic and Microkernel. The hybrid kernel takes good parts from both of the kernels. It has the modularity of the microkernel and the speed of the  Monolithic kernel. The speed comes because there is some “non-essential” code in the kernel space rather than the userspace.

The hybrid kernel runs the code as servers in the user space, this reduces the performance overhead.

What is the function of the kernel ...
What is the function of the kernel of an operating system?

Nano Kernel

These types of kernels, as the name suggests, have comparatively smaller code size. This reduced code size results in nano-second clock resolution. We will not go in-depth about nano kernel here since we don’t usually use it in our system. If you want to know more than you can read a dedicated article about nano kernels.

Exo Kernel

In these types of kernels, resource protection is separated from management, this allows the kernel to perform app-specific customization. This kernel is developed by MIT (Massachusetts Institution of Technology). Now, this kernel is also not used by us in our systems, so if you want to learn more then read an Exo Kernel dedicated article.

What will happen if the kernel is deleted?

First of all, you should know that it is impossible to remove the kernel in the first place. Even if you manage to remove the name from the file system, the kernel will still be present. The original file where the kernel code is present will stay intact. If you try to delete the files again, you will be shown that the files are gone. However, the files are not removed but only the path to the files is gone. So in a nutshell, it is not possible to delete the kernel but we will see WHAT IF somehow it happened. 

Once the kernel is removed, the applications will keep running but you will not be able to get any response from them (not able to use them). The system will stay turned on until you remove the power cable when the battery runs out. And next time you will try to start your PC, the boot menu will come up and then nothing will happen. And your system may be stuck in a loop, boot menu -> restart -> boot menu -> restart.

Summary

In the article, we saw a kernel and What is the function of the kernel of an operating system. If you want to understand the kernel more then read an in-depth article. We have covered everything there is to know about the kernel in the Operating System. Different functions are discussed in the article and you should not skip them even if you don’t want to go in-depth.

Gossipfunda | Android | Electronic | Tech News | App Review
error: Alert: Content is protected !!