Pages

Thursday, September 14, 2017

What is Kernel

What is the Kernel ?

Kernel is a program that is the core of a computer's operating system, with complete control over everything in the system. It is the first program loaded on start-up. It handles memory and peripherals like keyboards, monitors, printers, and speakers.

A kernel connects the application software to the hardware of a computer. It is responsible for interfacing all of your applications that are running in “user mode” down to the physical hardware, and allowing processes to get information from each other using inter-process communication (IPC).

The critical code of the kernel is usually loaded into a protected area of memory, which prevents it from being overwritten by applications or other, more minor parts of the operating system. The kernel performs its tasks, such as running processes and handling interrupts, in kernel space. In contrast, everything a user does is in user space: writing text in a text editor, running programs in a GUI, etc. This separation prevents user data and kernel data from interfering with each other and causing instability and slowness.

Different Types of Kernels

a) Monolithic
b) Microkernel &
c) Hybrid. 

a) Monolithic Kernel



In monolithic kernel the entire operating system works in kernel space. . Monolithic kernel is a single large process running entirely in a single address space. It is a single static binary file. All kernel services exist and execute in the kernel address space. Device drivers can be added to the kernel as modules

All the parts of a kernel like the Scheduler, File System, Memory Management, Networking Stacks, Device Drivers, etc., are maintained in one unit within the kernel in Monolithic Kernel

Examples : Linux is a monolithic kernel while OS X (XNU) and Windows 7 use hybrid kernels. 

Pros

More direct access to hardware for programs. Easier for processes to communicate between eachother. If your device is supported, it should work with no additional installations. Processes react faster because there isn’t a queue for processor time

Cons

Large install footprint
Large memory footprint
Less secure because everything runs in supervisor mode

Info: What is System Call. When a process makes requests of the kernel, it is called a system call. A system call is a mechanism that is used by the application program to request a service from the operating system.


The kernel's interface is a low-level abstraction layer. When a process makes requests of the kernel, it is called a system call. Kernel designs differ in how they manage these system calls and resources. A monolithic kernel runs all the operating system instructions in the same address space, for speed. A microkernel runs most processes in user space, for modularity.

b) Microkernel 

It is also known as μ-kernel is the near-minimum amount of software that can provide the mechanisms needed to implement an operating system (OS). These mechanisms include low-level address space management, thread management, and inter-process communication (IPC).

If the hardware provides multiple rings or CPU modes, the microkernel may be the only software executing at the most privileged level, which is generally referred to as supervisor or kernel mode. Traditional operating system functions, such as device drivers, protocol stacks and file systems, are typically removed from the microkernel itself and are instead run in user space.

In microkernels, the kernel is broken down into separate processes, known as servers. Some of the servers run in kernel space and some run in user-space. All servers are kept separate and run in different address spaces. Servers invoke "services" from each other by sending messages via IPC (Interprocess Communication). This separation has the advantage that if one server fails, other servers can still work efficiently.


Only the very important parts like IPC(Inter process Communication), basic scheduler, basic memory handling, basic I/O primitives etc., are put into the kernel. Communication happen via message passing. Others are maintained as server processes in User Space

Examples of micro kernels would be: Mach QNX AmigaOS Minix – zeitue. GNU Hurd is a great example of an OS running on a microkernel. It's still in active development and some popular Linux distros have a Hurd port 

Both Mac OS X and Windows are hybrid kernel as in more closely related to a monolithic kernel.

Pros

Portability, Small install footprint, Small memory footprint, Security

Cons

Hardware is more abstracted through drivers, Hardware may react slower because drivers are in user mode, Processes have to wait in a queue to get information, Processes can’t get access to other processes without waiting

No comments:

Post a Comment