What is Kernal & Basic Finality of Kernel
we can define a Kernel as the main component of most computer operating systems. It provides an interface between applications and actual data processing at the hardware level.
The kernel is considered the Heart of an Operating System. Kernel provides the lowest-level abstraction layer for the resources (especially processors and I/O devices) that application software must control to perform its function. It makes these facilities available to application processes through Inter-Process Communication (IPC) mechanism and System Call.
BASIC FUNCTION OF KERNEL:
As we have seen above the kernel is the Engine of any Operating System, so all the vital functions should e controlled and managed by kernel itself. There are various tasks and functions of a kernel but some of the important are given below:
1. Resource allocation- The kernel’s primary function is to manage the computer’s resources and allow other programs to run and use these resources. These resources are- CPU, Memory and I/O devices.
2. Process Management- A process defines which memory portions the application can access. The main task of a kernel is to allow the execution of applications and support them with features such as hardware abstraction.
To run an application, a kernel first set up an address space for the application, then loads the file containing the application’s code into memory, then set up a stack for the program and branches to a given location inside the program, thus finally starting its execution.
3. Memory Management- The kernel has full access to the system’s memory. It allows processes to safely access this memory as they require it. Virtual addressing helps kernel to create virtual partitions of memory in two disjointed areas, one is reserved for the kernel (kernael space) and the other for the applications (user space).
4. I/O Device Management- To perform useful functions, processes need access to the peripherals connected to the computer, which are controlled by the kernel through Device Drivers. A device driver is a computer program that enables the operating system to interact with a hardware device. It provides the operating system with information of how to control and communicate with a certain piece of hardware.
A kernel maintains a list of available devices. A device manager first performs a scan on different hardware buses, such as Peripheral Component Interconnect (PCI) or Universal Serial Bus (USB), to detect installed devices, then searches for the appropriate drivers. The kernel provides the I/O to allow drivers to physically access their devices through some port or memory location.
5. Inter-Process Communication- Kernel provides methods for Synchronization and Communication between processes called Inter- Process Communication (IPC). There are various approaches of IPC say, semaphore, shared memory, message queue, pipe (or named fifo), etc.
6. Scheduling- In a Multitasking system, the kernel will give every program a slice of time and switch from process to process so quickly that it will appear to the user as if these processes were being executed simultaneously. The kernel uses Scheduling Algorithms to determine which process is running next and how much time it will be given. The algorithm sets priority among the processes.
7. System Calls and Interrupt Handling- A system call is a mechanism that is used by the application program to request a service from the operating system. System calls include close, open, read, wait and write. To access the services provided by the kernel we need to invoke the related kernel functions. Most kernels provide a C Library or an API, which in turn invokes the related kernel functions.
There are few methods by which the respective kernel function can be invoked- using Software- Simulated Interrupt, or using a Gate Call, or by using a Special System Call Instruction and by using a Memory- based Queue.
8. Security or Protection Management- Kernel also provides protection from faults (error control) and from malicious behaviors (Security). One approach toward this can be Language based protection system, in which the kernel will only allow code to execute which has been produced by a trusted language compiler.