Kernel Architecture of Linux
Kernel is a small and special code which is the core component of Linux OS and directly interacts with hardware. It is the intermediate level between software and hardware which provides low level service to user mode’s components. It is fully developed in C language and file system architecture Moreover, it has different blocks which manage various operations. .In this tutorial we will learn about kernel architecture of Linux.
Kernel runs a number of processes concurrently and manages the various resources. It is viewed as a resource manager when several programs run concurrently on a system. In this case, the kernel is an instance that shares available resources like CPU time, disk space, network connections etc.
Types of kernel
Kernel architecture is classified into two types:
- Monolithic
- Micro Kernel
Monolithic Kernels
In the traditional monolithic kernel architecture, all the basic system services like process and memory management, interrupt handling etc. were packaged into a single module in kernel space. Module is an object file in which the whole code can be linked to kernel at run time. Huge space is consumed by traditional monolithic kernel and maintenance level is very low. It takes few hours for recompilation if some new feature is added because all the services are attached into one single module.
Modern monolithic kernel architecture consists of different modules which can be dynamically loaded and un-loaded. In this way maintainability is very easy because kernel needs to take care of only loaded module. Recompilation is not required upon added feature or some changes. Monolithic kernel is faster than micro kernel.
Micro kernels
Monolithic kernel architecture supports the modular approach. All service modules are not run in kernel space as compared to monolithic kernel. Device driver management, protocol stack, file system etc are run in user space. This reduces the kernel code size and also increases the security.
Fundamental Architecture of Linux
Fig. 1: Image showing Fundamental Architecture of Linux
Architecture of kernel divided into main two parts:
- User Space
- Kernel Space
User Space
All user programs and applications are executed in user space. User Space cannot directly access the memory and hardware. It accesses the hardware through kernel space. Processes or programs which are running in user space only access some part of memory by system call. Due to full protection, crashes in user mode are recoverable.
GNU C library provides the mechanism switching user space application to kernel space.
Kernel Space
All kernel programs are executed in kernel space. Kernel space accesses full part of memory and directly interacts with hardware like RAM, Hard disk etc It is divided in different blocks and modules which manage all operations (like file management, memory management, process management etc.) in kernel space and applications running in user space. Kernel space consists of system call interface, Kernel (core component of Linux) and device module.
System call interface is the intermediate layer between user space and kernel space. Each application which is run in user space can interface with kernel through system call interface. For example system call function on file operation are open ( ), write ( ), read ( ) etc.
Kernel is independent from hardware. It is common for all Hardware processors which are supported by Linux. You can run kernel on any processor like Intel, ARM, Atmel etc. It acts as a resource manager in Kernel space and performs process management, file management, memory management, Interrupt handler , scheduling of process, etc. It is a powerful structure which handles all kinds of operations.
Architecture of Kernel
Fig. 2: Image showing Full Architecture of Kernel
Kernel architecture follows modular approach. Each block in kernel (i.e. file management) is nothing but piece of code written in C language. Each block consists of powerful structure for handling various operations.
Process management
Process management is handling the management of various processes which are run at the same time. Process is an instance of ‘program in execution’ like open the file, access drive, access external resource (i.e. printer), etc. and can be created and destroyed. Process management gives the information of what’s happening with a processand manages its priorities, such as which address should be assigned to process, file allocated to process, state of process (like running, waiting, stop) etc. I will explain in brief about process in another tutorial.
Memory management
Memory management is the most important part of kernel which handles assignment of address space to process and application. Basically memory management assigns virtual memory instead of physical memory,whereby latter is the actual address space in RAM. Don’t be confused between physical and virtual memory. Assignment of virtual address overcomes the limitation of assignment of physical memory. Conversion from physical address to virtual address is performed by MMU (Memory Management Unit which provides the protection of memory interference, sharing of memory and allocation of virtual memory. Physical address space is divided into some block of memory called frame thatcontains a number of pages.
Linux File System
The Linux file system is a hierarchically data structured tree which organizes the file system. File is simple data structure (in form of some byte of memory) which can store any kind of data like text, image, video, music and whatever you want in computer. Linux file system is organized as a directory in tree form. Directory is a collection or group of files. Two types of directory are available in Linux system: 1) root 2) Sub directory. Root is main directory and cannot be accessed without permission of super user. It is the parent and main directory in file system denoted as forward slash ( / ). Sub directory is under the root directory which can be created or renamed by user. Linux supports number of file types like ext2, ext3, device file, block file, networking file system etc. Each file system is stored in different a disk partition.
Filed Under: Tutorials
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.