What is Kernel in Operating System?
The operating system is the most important program that runs on a computer. Where kernel is the central module of an operating system. It is the heart of OS which manages the core features of an OS. Using interprocess communication and system calls, it acts as a bridge between applications and the data processing performed at the hardware level.
The first attempt to create an OS that passed messages via kernel was in 1969 with the RC 4000 Multiprogramming System. Programmer Per Brinch Hansen discovered it was easier to create a nucleus and then build up an OS, instead of converting existing OSes to be compatible with new hardware.
The primary function is to mediate access to the computer's resources, including:
The central processing unit (CPU) - This central component of a computer system is responsible for running or executing programs. The kernel takes responsibility for deciding at any time which of the many running programs should be allocated to the processor or processors.
Random-access memory (RAM) - RAM is used to store both program instructions and data. Both need to be present in memory in order for a program to execute. Often multiple programs will want access to memory, frequently demanding more memory than the computer has available. The kernel is responsible for deciding which memory each process can use and determining what to do when not enough memory is available.
Input/output (I/O) devices - These include such peripherals as keyboards, mice, disk drives, printers, USB devices, network adapters, and display devices. The kernel allocates requests from applications to perform I/O to an appropriate device and provides convenient methods for using the device.
The kernel is the most fundamental part of an operating system. It can be thought of as the program which controls all other programs on the computer. When the computer starts, it goes through some initialization (booting) function, such as checking memory. It is responsible for assigning and un-assigning memory space which allows software to run. It provides services so programs can request the use of the network card, the disk or other pieces of hardware, manages the file system and sets interrupts for the CPU to enable multitasking.
The sole aim of the kernel is to manage the communication between the software and the hardware like CPU, disk memory etc. The kernel is responsible for low-level tasks like -
- Device management
- Process management
- Memory management
- Interrupt handling
- I/O communication
When an operating system is loaded into memory, the kernel loads first and remains in memory until the operating system is shut down again. Because it stays in memory, it is important for the kernel to be as small as possible while still providing all the essential services required by other parts of the operating system and applications.
The kernel code is usually loaded into a protected area of memory to prevent it from being overwritten by programs or other parts of the operating system. This separation prevents user data and kernel data from interfering with each other and causing instability and slowness.
Every operating system has a kernel. For example, the Linux kernel is used numerous operating systems including Linux, FreeBSD, Android, and others. But there are five types of kernels -
All operating system services run along the main kernel thread in a monolithic kernel, which also resides in the same memory area, thereby providing powerful and rich hardware access.
Define a simple abstraction over hardware that use primitives or system calls to implement minimum OS services such as multitasking, memory management, and interprocess communication.
Simplify the memory requirement by delegating services, including the basic ones like interrupt controllers or timers to device drivers
Run a few services in the kernel space to reduce the performance overhead of traditional microkernels where the kernel code is still run as a server in the user space.
Allocate physical hardware resources such as processor time and disk block to other programs, which can link to library operating systems that use the kernel to simulate operating system abstractions.