Basics of Kernel in Linux — Top Tech Notes

Manish Chandra
4 min readJul 11, 2022

--

A Linux kernel is a UNIX like operating system kernel. So obviously the kernel of Linux will be Unix like kernel. It is a computer program which is the core interface which connects the hardware components to the Software processes. So the software processes are those which we are trying to establish or trying to interpret. Normally we just type our command on shell and hit enter and we get result. We don’t know what happens in the background. We discussed it in brief in previous post on Linux shell. Let’s understand it once again.

So basically what happens is, whenever we type in the command on shell it is passed to the kernel which is in middle. A kernel is a very huge program. It could contain somewhere around or even more than 2 million lines of code. It is a very complicated and helpful program. The kernel is the main interconnection between the software application or the software processes and the hardware components.

So let’s say we are trying to find out how much RAM our system is using. We cannot directly go and check the RAM in our system. We instead use the process running in the background which connects to the hardware components and checks how much RAM is being used and then sends that information back to us. So this is what the kernel does. Let’s see the top operations performed by Kernel.

There are basically top 4 operations performed by a Kernel are Resource Management, Memory Management, Device Management and System Call. Let us get a brief idea about each of these operations.

Resource Management: Kernel decides which process gets a resource for an operation. Let’s say you are running multiple processes and in those multiple processes two processes needs the same resource for an operation. In this case the Kernel will decide which operation should use that resource first and which should use it second. This is because this same resource requirement by multiple processes should not end up in a deadlock situation. To avoid this kernel performs an operation which basically chooses which process needs the resource right now or it may delay the process of execution. So it might give it to a process which takes lesser time first and then it gives resource to a process which takes longer time. So there are varieties of operation that can be performed in resource management. But this is one of the main operations that Kernel does.

Memory Management: Memory management is very important for any server or computer. Even if you are using a windows system with 1 TB of space, then also memory management is very important. Memory management is take care by your system operating system in Windows. Similarly in Linux also, kernel takes care of memory management. Kernel has complete access to the system memory and must efficiently manage to allocate memory access to process. But why do we need memory? Memory is not for storing content. Memory is to run processes efficiently and effectively. So the kernel should know how much memory should be allocated to each processes so that our system is not completely taken away of free memory. Let’s say we have 100 MB of memory and there are 10 processes. Then our system kernel should decide how much memory does each process deserve to use and it should allocate that much memory to the process efficiently.

Device Management: Device management is pretty common in every single operating system. So if you are using a windows system and you enter a pen drive into USB port of your machine, you will be able to see that device in your computer. So like that, device management is also taken care by Kernel. If we connect devices such as printer or pen drive, the kernel will detect the device and the system will establish connection to the peripherals. So if I connect a pen drive then the Linux kernel will first detect it. And there is a separate directory in kernel which is knows as /dev. This particular directory is especially for device management in Linux operating system. Any device entering into any Linux operating system will have a separate directory for them in “/dev”. So if we enter pen drive into linux system then that pen drive will have a separate directory within the “/dev” directory from where we can access it. So in this way Linux kernel takes care of device management.

System Calls: This is an interface between a process and the operating system. When the process does not have permissions to access a resource, a system call provides it without the process accessing the resource directly. So basically if we are running a process but we have not given the process enough permissions to use a particular resource, then we can use system calls for that process by embedding system calls in our shell script or code so that when that particular system calls is used, their process will be given access to the resource indirectly. So the purpose of system calls is to make sure not to stop the process from running. It does not interrupt our execution but it helps to complete execution as fast as possible. We also use system calls to do more operations at operating system level. There are various system calls that we can use. For example, we can use system call to abort a particular process immediately.

So these are the four important operations performed by Kernel. You must understand that Kernel is the main component of any Linux distribution. And the Kernel manages all of the top operations of a Linux distribution.

If you like this post, then do not forget to share this post with your friends and subscribe to our newsletter so that you can receive timely update whenever we publish any new post.

Subscribe to our newsletter!

Originally published at https://toptechnotes.com on July 11, 2022.

--

--

Manish Chandra
Manish Chandra

Written by Manish Chandra

I an an IT professional & owner of toptechnotes.com &have been working in IT industry for more than 15 years. Apart from work I love to read books.

No responses yet