cover-img

A Layman's Guide to Linux: The Kernel

Exploring the Core of Operating Systems: An Introduction to Kernels

11 December, 2022

5

5

0

A kernel is the central part of an operating system that manages the system's resources and interactions with the computer hardware. It is the core of the operating system that provides basic services for all other parts of the system.
In this blog, we will discuss the different types of kernels, their key responsibilities, and the benefits they provide for operating systems. We will also explore some of the challenges and limitations of kernels, and how they are evolving to meet the needs of modern computing systems.

The Kernel

The Kernel is a Computer program that is at the very heart of a computer's Operating system with complete control over everything in that system. After the Boot Loader has completed its instructions, the Kernel is loaded into the memory.
It handles the rest of the startup process as well as the Input-Output requests from the software. It translates them into the Data Processing Instructions for the Central Processing Unit i.e., CPU. It handles memory and peripherals like Keyboard, Monitor, Printers and Speakers.
img

The Kenel

Types of Kernels

There are two types of Kernels - Monolithic Kernels and Micro Kernels. A Monolithic Kernel runs all the operating system instructions in the same address base for speed. A micro Kernel runs most processes in user space for modularity.
Linux uses the Monolithic Kernel and the heard from GNU Project uses micro Kernel. Proprietary Operating systems like Windows and Mac use Hybrid Kernels. The Hybrid Kernels approach combines the speed and simple design of a Monolithic Kernel with the modularity and execution safety of a micro Kernel.
img

Types of Kernels

Though Monolithic Kernel seems to have the most simple design. It does however have the largest footprint and complexity over the other types of Kernels. One thing that Linux Developers did to get around issues linked with this design feature was to make Kernel Modules which could be easily loaded and unloaded at runtime. This means you can add or remove the features of your Kernel on the fly.
This can go beyond just adding hardware functionality to your Kernel. It can also allow the entire kernel to be replaced without needing to reboot your computer in some instances.
Now let us look at the components of Kernel.

Kernel Modules

One thing that makes the Linux Kernel unique is the fact that it can power many of your devices out of the box i.e., even if the device drivers for your peripherals are missing in some instances. This is performed by the use of Kernel modules. These modules are essential for keeping the Kernel functioning with all of your Hardware without consuming all of your available memory.
A Loadable Kernel Module or an LKM typically adds functionality to your base Kernel for things like devices, file systems and system calls. LKMs have the file extension ".ko". They are present in the "/lib/modules" directory.
You can easily customize your Kernel by setting modules to load or not load during startup with the menu config command or by editing your "/boot/config" file. Or you can load and unload modules on the fly with the modprobe command.
Third-party and closed-source modules are available in some Linux Distributions like Manjaro or Ubuntu. The developers of the software only provide the precompiled drivers without any source code.
img

Modules

Memory Management

Another feature of the Linux Kernel is Memory Management. The essential requirement of managing memory is to provide ways dynamically allocate portions of memory to programs at their request and free it for reuse when no longer needed. This is important because at any given time your system should be able to handle multi-processing.
Several methods have been devised to increase the efficiency of memory management. For example the memory chips on the motherboard. The hard drive also has space allocated for swap or virtual memory. Virtual memory systems separate the memory addresses used by a process from the actual physical addresses allowing separation of process and increasing the size of the virtual address space beyond the available amount of RAM using the mentioned swap space.
The quality of the virtual memory manager can have an extensive effect on overall system performance.
Now let us discuss the Network capabilities of the Linux Kernel.

Network Stack

Network Stack is what allows the applications to be able to access a network through a physical networking device. Networking Devices can be Modems, Cable Modes, ISDN Wi-Fi devices or Ethernet.
There are 7 layers to the network stack. The application layer is the part of the user space or what you see on the screen and interact with. The next 5 layers are in the kernel space which contains a system call interface, Network Protocol, Device agnostic interface and device drivers. The 7th layer is your physical hardware.
Jobs performed on the network stack are twofold. First, the user makes the request such as searching for a file. In the second step when the request is filled the data is returned to the user.

The request starts from the applications such as a Web Browser and goes through the above-mentioned layers and then to the physical hardware.

At this point, the request exist as a Data Packet on the network medium. Once the request is received at the file location, the file is sent back to the requesting system.

Once this system receives the file, its data packets enter the physical hardware and go back through the various layers until it reaches the application layer.

At the application layer, the web browser is given the requested file and then the user can open it.

Process Management

There are two types of processes in Linux.
The first is the foreground process, also known as the interactive process. These are initialized and controlled through a terminal session or by activating a desktop file from the menu. In other words, there has to be a user connected to the system to start such a process. They haven't started automatically as a part of the system function or system services.
The second is the Background process. They are also referred to as non-interactive or automatic processes. They are not connected to user commands and don't expect any user input. There are several types of background processes called Daemons. They are started as system tasks and run as services spontaneously. However, they can be controlled by the user via an init system.
Linux is a multi-user system allowing different users to run various programs on the system. Each running instance of a program must be identified uniquely by the kernel and a program is identified by its process ID also known as PID as well as its parent process ID or the PPID. Therefore processes can be further categorized into parent processes.
These processes can create other processes during the runtime. During execution, a process changes from one state to another depending on its environment or its circumstances.
img

Process States

In Linux, a process has the following possible states:

Running (R): When a new process is started, it’ll be placed into the running or runnable state.

Sleeping: There are two different sleeping states: the uninterruptible sleeping state (D) and the interruptible sleeping state (S). The uninterruptible sleeping state will only wait for the resources to be available before it transits into a runnable state, and it doesn’t react to any signals. On the other hand, the interruptible sleeping state (s) will react to signals and the availability of resources.

Stopped: In this state, a process is stopped, usually by receiving a signal.

Zombie: In this state, the process is dead. It has been halted but it still has an entry in the process table.

Virtual File System

The Virtual File System (VFS) provides a common interface abstraction for the file systems. The VFS provides a switching layer between the system call interface and the file systems supported by the Kernel.
img

Virtual File System

At the top of a Virtual File System is a common API abstraction of functions such as open, close, read and write. At the bottom of the VFS are the file system abstractions that define the upper-layer functions and how they are implemented. These are plugins for the given file system.
Below the File system layer is a buffer cache which provides a common set of functions to the filesystem layer independent of any particular file system. This caching layer optimizes access to the physical devices by keeping data around for a short time or reading ahead so that the data is available when needed.
Below the buffer cache are the device drivers which implement the interface for the particular physical device.

System Calls

The System call is the fundamental interface between an application and the Linux Kernel. System calls are how a program enters the Kernel to perform some task. Programs use system calls to perform a variety of operations such as creating processes doing network and file operations and much more.
img

System Calls Inteface

In most systems, system calls can only be made from user space processes while in other systems privileged system code also issues system calls. System calls are made available by the operating system to provide well-defined implementations for various operations.
The operating system executes at the highest level of privilege and allows applications to request services via system calls which are often initiated via interrupts. An interrupt automatically puts the CPU into some elevated privilege level and then passes control to the Kernel. The kernel determines whether the calling program should be granted the requested service.
If the service is granted the kernel executes a specific set of instructions over which the calling program has no direct control.

Conclusion

In conclusion, the kernel is an essential part of an operating system, providing the basic services and abstractions needed to manage the system's resources and hardware. It enables multitasking and makes it possible for the software to run on a variety of different hardware platforms.

linux

develevate

howto

operating

systems

kernel

5

5

0

linux

develevate

howto

operating

systems

kernel

Aviral Sharma
Software Engineer | Frontend Developer | NextJs Ninja

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.