What is kernel?

A computer system takes command from the user through the operating system to perform a task. It can be in a graphical or command-line interface. But the computer system can only understand binary language. So, the translation between simple command or instruction into binary language is done by the core component of the operating system called Kernel.
The kernel is not an operating system it is a core part of any operating system. Kernel plays a mediator role between hardware and software systems.
A kernel is the most critical element. If the kernel fails, the rest of the system fails. The kernel is responsible for managing tasks like process management, CPU resource scheduling, disk management, memory management, etc. The actual size of a kernel varies from machine to machine, depending upon what features are compiled.
Whenever a system starts, the kernel is the first program that is loaded into the memory area after the bootloader. It remains in memory until the system power is on.

The functions of Kernel
The kernel controls and manages all primary tasks of OS.
Process management: A process is an instance of a computer program that is being executed. The kernel manages the creation, execution, and termination of the process to avoid the deadlock situation. The process management is very important for the better functionality of an operating system and all this is handled by the kernel.
Memory management: All processes need some memory space. So, the kernel allocates the memory to every process. The kernel keeps track of the memory about which part of the memory space is currently allocated and which part of the memory space is available for other processes.
Device management: The kernel includes device driver support for a large number of pc hardware devices like graphics cards, network cards, hard disks, etc.
Interrupt handling: While executing the processes, sometimes the condition occurs where some tasks need more priority and need to be handled first. In such cases, the kernel has to interrupt the execution of current processes and handled the task which has more priority. 
I/O communication: The kernel is also responsible for handling input and output devices through device drivers. A device driver is a computer software program that enables the operating system to interact with the hardware devices. So, all the instruction that the system receives from the user and the output provided to the user via different applications is handled by the kernel.
Inter-process communication (IPC): The kernel provides a method for synchronization and communication between two processes with each other in order to perform a task and share data. There are various approaches of IPC such as FIFO, message queues, shared memory, semaphores, signals, pipes.

Types of Kernel
Monolithic kernel: In a monolithic kernel user services and kernel services are reside in the same memory area.

It increases the size of the kernel as well as increases the size of the operating system. As there is no separate user space and kernel space in the memory area, so the execution of the process is faster in the monolithic kernel.
This kernel provides various services such as CPU scheduling, memory management, file management, process scheduling, and other functions through system calls.  Due to the large size, it is difficult to maintain the kernel.
Microkernel: In microkernel kernel user services and kernel, services reside in a different memory area. It decreases the size of a kernel as well as the size of the operating system because the user services are store in the user space and kernel services are store in kernel address space.
The execution of the process is slower in the microkernel. In microkernel architecture maintenance is easier and patches can be tested separate instances from the production instance. 
Hybrid kernel: Hybrid kernel architecture is a combination of microkernel and monolithic kernel architecture. This kernel has speed and simpler design of monolithic kernel with the modularity of microkernel.
A hybrid kernel runs some services in the kernel space in order to run code more quickly than it would be in user space and also to reduce some performance overhead because it has traditional code from microkernel while still running kernel code as the server in the user space.
Nanokernel: In a nanokernel, the kernel code is very small. It executes code in the privileged mode of the hardware without system services.
Exokernel: Exokernel is developed by MIT (Massachusetts Institute of Technology). It is an operating system kernel that seeks to provide application-level management of hardware resources. The exokernel is designed not to implement all the abstractions but to impose as few abstractions as possible on application developers, enabling them to make as many decisions as possible about hardware abstractions. The design of the exokernel is very complex.


User mode vs Kernel mode


User mode: When the computer system starts an application program such as a photo editor then the system is in user mode. The transition between user mode to kernel mode happens when the application requests for a service from the operating system or an interrupt or a system call occurs.
By default, the mode bit is set to 1 in the user mode and it is changed from 1 to 0 while switching from user mode to kernel mode.

Kernel mode: Kernel mode is also called privileged mode or system mode. When the system boots, hardware starts in kernel mode and after the operating system is loaded it executes applications in user mode. In kernel mode, the processes get single memory address space.
When the process executes in user mode it requires hardware resources such as RAM, for that the process should send a request to the kernel and this request is sent through system calls and then the system enters kernel mode from user mode.
After the task is completed the kernel-mode changes back to user mode. This transition is called  “context switching”.
By default, the mode bit is set to 0 in the kernel mode and it is changed from 0 to 1 while switching from a kernel mode to user mode.

What is Linux, GNU and GPL?

Linux is an open-source operating system. An operating is system software that manages the computer hardware. It enables the execution of application programs and acts as an interface between the computer user and the computer hardware.


Linus Torvalds created Linux kernel in 1991. He was studying computer science at the University of Helsinki in Finland where he had been using a paid version of Unix-like operating system called Minix. He was unhappy with Minix and then decided to write a complete Unix-like proprietary kernel called Linux. He used C programming language to write a Linux kernel and its functionality is similar to UNIX.

There are two ways to work with a Linux system:

A graphical user interface.
A command-line interface.

Features of Linux
  • Portability: Linux is a portable software that means it can work on different types of hardware in the same way.
  • Multitasking: In Linux, multiple applications can run at the same time.
  • Multi-user: Multiple users can access the system resources like memory, ram, and application programs at the same time.
  • Security: Linux provides a firewall or Iptables and SElinux (Security Enhance Linux), user security using authentication features like password protection with hashing algorithms, access control list to specific files and encryption of data.
  • Shell: Linux provides a special interpreter called BASH (Bourne again shell) that process commands. A shell interpreter takes command from a user in plain text format and tells the operating system to run the task.
  • Open source: Linux source code is available for free so anyone can download, modify as per your needs or requirements.
  • File System: Linux file system is in a hierarchical format.

GNU Project

In 1983, Richard Stallman began the development of free software replacement for UNIX and it’s called GNU.

GNU is a short form of (GNU’s Not Unix). It is a free operating system but it was the missing kernel for the operating system and in 1992 Linus Torvalds join the GNU project with he’s Linux Kernel so it’s become GNU/Linux.

There are four main purposes of the GNU project is to give computer users a:  
Freedom to study the source code and changed and run the program as you wish.
Freedom to modify the code or program to suit your needs.
Freedom to share copies, either for free or for fees.
Freedom to distribute a modified version of the program to contribute to your community so they can get benefit from it.

GNU GPL (General Public License)

Any software licensed under GPL is free licensed software. The end users get the freedom to study, share, modify and run the software under GPL.

The first version was published in February 1989, the second version was published in June 1991 and the latest the third version was published in June 2007.

Under the GPL license program you are allowed to sell the modified version of the software. You are also allowed to introduce additional points in terms and conditions.





Featured Post

Managing user and groups, UID and GID in Linux

What are users in the operating system? A user is a person who accesses or utilizes computer resources or network services. In order to ...

Popular Posts