Kernel in Operating System
A kernel is the core part of an operating system. It acts as a bridge
between software applications and the hardware of a computer.
The kernel manages system resources, such as the CPU, memory, and
devices, ensuring everything work together smoothly and efficiently.
It handles tasks like running programs, accessing files, and connecting to
devices like printers and keyboards.
An Operating System includes the kernel as its core, but also provides a
user interface, file system management, network services, and various
utility applications that allow users to interact with the system
APPLICATIONS
KERNAL
CPU MEMORY DEVICES
Facilitates communication between hardware and user applications.
Ensures efficient and secure multitasking.
Manages system stability and prevents unauthorized resource access.
Types of Kernel
The kernel manages the system’s resources and facilitates
communication between hardware and software components. These
kernels are of different types let’s discuss each type along with its
advantages and disadvantages:
1. Monolithic Kernel
It is one of the types of kernel where all operating system services
operate in kernel space. It has dependencies between systems
components. It has huge lines of code which is complex.
Example:
Unix, Linux, Open VMS, XTS-400 etc.
Advantages
Efficiency: Monolithic kernels are generally faster than other types of
kernels because they don’t have to switch between user and kernel
modes for every system call, which can cause overhead.
Tight Integration: Since all the operating system services are running in
kernel space, they can communicate more efficiently with each other,
making it easier to implement complex functionalities and optimizations.
Simplicity: Monolithic kernels are simpler to design, implement, and debug
than other types of kernels because they have a unified structure that
makes it easier to manage the code.
Lower latency: Monolithic kernels have lower latency than other types of
kernels because system calls and interrupts can be handled directly by
the kernel.
Disadvantages
Stability Issues: Monolithic kernels can be less stable than other types of
kernels because any bug or security vulnerability in a kernel service can
affect the entire system.
Security Vulnerabilities: Since all the operating system services are
running in kernel space, any security vulnerability in one of the services
can compromise the entire system.
Maintenance Difficulties: Monolithic kernels can be more difficult to
maintain than other types of kernels because any change in one of the
services can affect the entire system.
Limited Modularity: Monolithic kernels are less modular than other types of
kernels because all the operating system services are tightly integrated
into the kernel space. This makes it harder to add or remove
functionality without affecting the entire system.
2. Micro Kernel
It is kernel types which has minimalist approach. It has virtual memory
and thread scheduling. Micro Kernel is more stable with less services in
kernel space. It puts rest in user space. It is use in small os.
Example :
Mach, L4, AmigaOS, Minix, K42 etc.
Advantages
Reliability: Microkernel architecture is designed to be more reliable than
monolithic kernels. Since most of the operating system services run
outside the kernel space, any bug or security vulnerability in a service
won’t affect the entire system.
Flexibility : Microkernel architecture is more flexible than monolithic
kernels because it allows different operating system services to be
added or removed without affecting the entire system.
Modularity: Microkernel architecture is more modular than monolithic
kernels because each operating system service runs independently of
the others. This makes it easier to maintain and debug the system.
Portability: Microkernel architecture is more portable than monolithic
kernels because most of the operating system services run outside the
kernel space. This makes it easier to port the operating system to
different hardware architectures.
Disadvantages
Performance: Microkernel architecture can be slower than monolithic
kernels because it requires more context switches between user space
and kernel space.
Complexity: Microkernel architecture can be more complex than monolithic
kernels because it requires more communication and synchronization
mechanisms between the different operating system services.
Development Difficulty: Developing operating systems based on
microkernel architecture can be more difficult than developing
monolithic kernels because it requires more attention to detail in
designing the communication and synchronization mechanisms between
the different services.
Higher Resource Usage: Microkernel architecture can use more system
resources, such as memory and CPU, than monolithic kernels because it
requires more communication and synchronization mechanisms between
the different operating system services.
3. Hybrid Kernel
It is the combination of both monolithic kernel and microkernel. It has
speed and design of monolithic kernel and modularity and stability of
microkernel.
Example :
Windows NT, Netware, BeOS etc.
Advantages
Performance: Hybrid kernels can offer better performance than
microkernels because they reduce the number of context switches
required between user space and kernel space.
Reliability: Hybrid kernels can offer better reliability than monolithic
kernels because they isolate drivers and other kernel components in
separate protection domains.
Flexibility: Hybrid kernels can offer better flexibility than monolithic kernels
because they allow different operating system services to be added or
removed without affecting the entire system.
Compatibility: Hybrid kernels can be more compatible than microkernels
because they can support a wider range of device drivers.
Disadvantages
Complexity: Hybrid kernels can be more complex than monolithic kernels
because they include both monolithic and microkernel components,
which can make the design and implementation more difficult.
Security: Hybrid kernels can be less secure than microkernels because
they have a larger attack surface due to the inclusion of monolithic
components.
Maintenance: Hybrid kernels can be more difficult to maintain than
microkernels because they have a more complex design and
implementation.
Resource Usage: Hybrid kernels can use more system resources than
microkernels because they include both monolithic and microkernel
components.
4. Exo Kernel
It is the type of kernel which follows end-to-end principle. It has fewest
hardware abstractions as possible. It allocates physical resources to
applications.
Example :
Nemesis, ExOS etc.
Advantages
Flexibility: Exokernels offer the highest level of flexibility, allowing
developers to customize and optimize the operating system for their
specific application needs.
Performance: Exokernels are designed to provide better performance than
traditional kernels because they eliminate unnecessary abstractions and
allow applications to directly access hardware resources.
Security: Exokernels provide better security than traditional kernels
because they allow for fine-grained control over the allocation of system
resources, such as memory and CPU time.
Modularity: Exokernels are highly modular, allowing for the easy addition
or removal of operating system services.
Disadvantages
Complexity: Exokernels can be more complex to develop than traditional
kernels because they require greater attention to detail and careful
consideration of system resource allocation.
Development Difficulty: Developing applications for exokernels can be
more difficult than for traditional kernels because applications must be
written to directly access hardware resources.
Limited Support: Exokernels are still an emerging technology and may not
have the same level of support and resources as traditional kernels.
Debugging Difficulty: Debugging applications and operating system
services on exokernels can be more difficult than on traditional kernels
because of the direct access to hardware resources.
5. Nano Kernel
It is the type of kernel that offers hardware abstraction but without
system services. Micro Kernel also does not have system services
therefore the Micro Kernel and Nano Kernel have become analogous.
Example :
EROS etc.
Advantages
Small Size: Nanokernels are designed to be extremely small, providing only
the most essential functions needed to run the system. This can make
them more efficient and faster than other kernel types.
High Modularity: Nanokernels are highly modular, allowing for the easy
addition or removal of operating system services, making them more
flexible and customizable than traditional monolithic kernels.
Security: Nanokernels provide better security than traditional kernels
because they have a smaller attack surface and a reduced risk of errors
or bugs in the code.
Portability: Nanokernels are designed to be highly portable, allowing them
to run on a wide range of hardware architectures.
Disadvantages
Limited Functionality: Nanokernels provide only the most essential
functions, making them unsuitable for more complex applications that
require a broader range of services.
Complexity: Because nano kernels provide only essential functionality,
they can be more complex to develop and maintain than other kernel
types.
Performance: While nanokernels are designed for efficiency, their
minimalist approach may not be able to provide the same level of
performance as other kernel types in certain situations.
Compatibility: Because of their minimalist design, nano kernels may not be
compatible with all hardware and software configurations, limiting their
practical use in certain contexts.
Functions of Kernel
The kernel is responsible for various critical functions that ensure the
smooth operation of the computer system. These functions include:
1. Process Management
Scheduling and execution of processes.
Context switching between processes.
Process creation and termination.
2. Memory Management
Allocation and deallocation of memory space.
Managing virtual memory.
Handling memory protection and sharing.
3. Device Management
Managing input/output devices.
Providing a unified interface for hardware devices.
Handling device driver communication.
4. File System Management
Managing file operations and storage.
Handling file system mounting and unmounting.
Providing a file system interface to applications.
5. Resource Management
Managing system resources (CPU time, disk space, network bandwidth)
Allocating and deallocating resources as needed
Monitoring resource usage and enforcing resource limits
6. Security and Access Control
Enforcing access control policies.
Managing user permissions and authentication.
Ensuring system security and integrity.
7. Inter-Process Communication
Facilitating communication between processes.
Providing mechanisms like message passing and shared memory.
The kernel data structures are very important as they store data about the current state of the system. For example, if a
new process is created in the system, a kernel data structure is created that contains the details about the process.
Most of the kernel data structures are only accessible by the kernel and its subsystems. They may contain
data as well as pointers to other data structures.
Kernel Components
The kernel stores and organizes a lot of information. So it has data about which processes are running in
the system, their memory requirements, files in use etc. To handle all this, three important structures are
used. These are process table, file table and v node/ i node information.
Details about these are as follows:
Process Table
The process table stores information about all the processes running in the system. These include the
storage information, execution status, file information etc.
When a process forks a child, its entry in the process table is duplicated including the file information and
file pointers. So the parent and the child process share a file.
File Table
The file table contains entries about all the files in the system. If two or more processes use the same file,
then they contain the same file information and the file descriptor number.
Each file table entry contains information about the file such as file status (file read or file write), file
offset etc. The file offset specifies the position for next read or write into the file.
The file table also contains v-node and i-node pointers which point to the virtual node and index node
respectively. These nodes contain information on how to read a file.
V-Node and I-Node Tables
Both the v-node and i-node are references to the storage system of the file and the storage mechanisms.
They connect the hardware to the software.
The v-node is an abstract concept that defines the method to access file data without worrying about the
actual structure of the system. The i-node specifies file access information like file storage device,
read/write procedures etc.