Friday, May 31, 2019

What is Kernel (Operating System)? - Definition

Definition: The operating system provides us a graphic interface to give the command to the computer system. But system can’t understand these commands directly. Translation of code into binary language done by the core component of an operating system (OS), i.e., KERNEL. User deal with the lowest layer of kernel and then kernel deal with system.

Kernel plays a role of mediator between system hardware and software. The kernel is not an operating system (OS); it is a central module of operating system. It is the first program that loaded into protected memory area during the booting process. It remains present in memory till the system power is on. The kernel is a low-level abstraction layer. User’s operation used a system call to interact with system.System calls invoke kernel, and then kernel executes user’s operation. Kernel use space to manage all the working of a system like process management, memory management, device management, I/O management and the user using userspace for running program or writing a program.

Type of Kernel

According to design and functionality, we have many kinds of kernels.

Monolithic Kernel

A monolithic kernel is a single code program with the ability to load OS services in single address space of memory (Kernel Space).All OS services run in privileged mode. All services like memory management process management, I/O drivers, and memory driver’s lies in kernel space reduce access time give higher performance.
Monolithic kernel code is more significant than microkernel code. Due to large size, it is difficult to maintain the kernel. If services occur in kernel code, the entire system will stop to work. A monolithic kernel is not portable, so different platform required different kernel.

Microkernel

Microkernel used both kernel and userspace to run all the system processes. Kernel divided into various processes known as services. Minimum of services like IPC (Inter-Process Communication), basic scheduler, or scheduling primitives, basic memory handling, primary I/O primitives are in kernel space. All services like Scheduler, memory handling, file systems, and network stacks are separately running in userspace. It reduces the size of kernel
Microkernel used system calls to implement thread management, inter-process communication, and memory management. Processes which are handled by the kernel in userspace are known as servers. Message passing system is used to control server request. A large number of system calls takes lots of time for context switching which makes the kernel slow as a comparison to Monolithic Kernel. QNX and the HURD used a microkernel. Microkernels are best for small process system. So less complication in process management.
Monolithic kernels designed for kernel space or Microkernel is intended for user and kernel space. Monolithic model performance is more efficient than microkernel. The monolithic kernel used share kernel memory concept but the message is passing in IPC system of microkernel design makes it less useful.

Hybrid Kernel

A hybrid kernel is extending version of a microkernel with adding some functionality of Monolithic kernel. A hybrid kernel divided into services same as a microkernel, and they all executed in same kernel space as the Monolithic kernel. NT kernels for windows and XNU kernel used by Apple for macOS.
Kernel mode contains Application PC, device drivers and virtual memory, scheduling process. It reduces the overhead of message passing and context switching time. File server and UNIX server are in user mode. The file server is memory area where the application gets executed.

Difference between Operating System and Kernel

OS is system software package and kernel is a part of OS who manage all processes and devices. The operating system is an interface between user and hardware. The kernel is an interface between software and hardware. Kernel helps the program to communicate with peripheral devices.

Function of Kernel

The kernel is function manager for OS process. Its controls and manages all the primary tasks of OS.
Memory Management : Kernel provides virtual and physical memory to processes for completing their execution. If a process is not ending on physical memory, then kernel provide virtual space on hard disk for storing the operation. This concept is known virtual mapping. When a program needs data which is not currently present in RAM, the CPU signals to the kernel for data and the kernel responds to CPU by writing the contents of an inactive memory block to disk(creating a space for requiring data) and replacing it with the data requested by the program. This scheme is known as demand paging.
Scheduler : Kernel acts as a scheduler for processes during execution. At a given time single process can be executed by the processor. The kernel allocates the processor to one of the programs from the list of the running application.
Device Management : Kernel controls the activity of peripheral devices through device drivers. Device drivers are the program that helps the operating system to interact with hardware devices. Device driver program provide an interface and help OS to deal with peripheral devices like printer, scanner, modems, keyboard, mouse, etc. The driver translates the operating system function calls into device-specific calls. Device drivers detect the installed devices and searches for device drivers when the system gets started.
The process used system call mechanism to deal with Operating System’s Kernel. A system call is service call to the kernel for taking permission for process execution. A system call is machine code instruction used by the application program to get the service permission from Operating system.
The kernel also manages the Random Access Memory. It allocates the memory to both instruction and data for execution. It decides which process should reside in RAM and how much memory a process require for their implementation? We know that multiple process’s data and related instructions lied in RAM. The kernel handles many operations using a different mechanism

No comments:

Post a Comment