Functions of Kernel
A Kernel performs many tasks, as we have discussed above. Now, let's learn about the functions performed by Kernel in detail. We have listed the tasks performed by Kernel in the below-given list.
Memory Management
The Kernel has full access to the computer's memory. Whenever a process requires some memory, the Kernel enables that process to safely access the memory, ensuring that no two applications crash into each other. The Kernel uses the paging and segmentation techniques of virtual addressing to give access to memory to the processes safely.
Device Management
The processes often need access to the computer's peripheral devices to perform their tasks. For example, the application needs access to the camera to record a video. The Kernel is responsible for controlling and managing these peripheral devices using device drivers. Device drivers are programs for specific devices which enables the OS to control them.
Accessing Computer Resources
A kernel is responsible for accessing computer resources such as RAM and I/O devices. Kernel decides which memory is to be used by each process and what to do if the required memory is unavailable.
Resource Management
The Kernel is responsible for sharing the available resources between various processes. It is one of the most important functionalities of the Kernel. It must ensure that each process has uniform access to the available resources. It is also responsible for the communication between processes, i.e., inter-process communication (IPC) and context-switching between processes.
Must Read Process Management in OS
Types of Kernel
There are five types of Kernel. Each of them is mentioned below with its explanation, advantages, and disadvantages.
Monolithic Kernels
The Kernel and userspace use the same memory space in a monolithic kernel. This means that no different memory space is used for user services and kernel services. The OS's overall size increases since it uses the same memory space. The execution of processes is faster in this type of Kernel as the same memory space is used for user and kernel services.
Example: Unix, Linux, XTS-400, etc.
Advantages
- Execution of processes is faster.
- Since it is a single piece of software, its sources and compiled form are smaller.
Disadvantages
- If a new service is to be added, the whole operating system needs to be modified.
- This type of Kernel is not portable. For each different architecture, the Kernel needs to be rewritten.
- If a service generates an error, the whole system may crash.
- Its size is larger and hence difficult to manage.
Microkernel
In this type of Kernel, the user and Kernel services are implemented into two different address spaces, i.e., user and kernel spaces. It is easier to manage and maintain than Monolithic Kernel, but it may perform slower if many system calls and context switching are made.
Microkernels provide only some essential services like defining memory address space, Inter-Process Management, and process management. The Kernel does not offer other services like networking. Instead, they are handled by a userspace program known as Server.
In microkernels, there will be no system crash when a process crashes, and it can be resolved by just restarting the error-caused services.
Example: Amigos, Minix, L4, etc.
Advantages
- Easily manageable
- New services can be easily added without modifying the existing OS.
- If a kernel process crashes, a system crash can be prevented by restarting the error-caused services. Hence it is more stable.
Disadvantages
- System performance is reduced due to the increased requirement of software for interfacing.
- Process management in microkernel is complicated.
Hybrid Kernel
Hybrid Kernels are a combination of both Monolithic kernels and Microkernels. It combines the speed of Monolithic Kernel with the modularity of Microkernels. It is similar to a microkernel, but it also includes some additional code in kernel space to enhance the system performance. Hybrid Kernel allows to run some services like network stack in kernel space, but it still allows kernel code like device drivers to run as servers in userspace.
Example: Windows NT, BeOS, Netware, etc.
Advantages
- No requirements for a reboot for testing
- Third-party technologies can be integrated rapidly.
Disadvantages
- Possibility of more bugs due to more interfaces to pass-through
- It is challenging for the administrators to maintain the modules.
Nanokernel
In Nanokernel, the complete code of the Kernel is very small. This means that the code getting executed in the privileged mode of hardware is very small. In Nanokernel, the term nano defines the support for a nanosecond clock resolution.
Example: EROS, etc.
Advantages
- It can provide hardware abstraction even with a very small size.
Disadvantages
- It lacks the system services.
Exokernel
In Exokernel, resource protection is separated from the management part, which allows us to perform application-specific customization. It follows the end-to-end principle. It has the fewest hardware abstractions possible and allocates the physical resources to applications.
Advantages
- It provides better support for application control.
- Improved performance of applications.
- Applications are allowed to have their optimized memory management system.
Disadvantages
- The design of exokernel interfaces is complex.
The whole article can be summarized as given below.
A kernel is the core part of an Operating System. It comprises five types: Monolithic Kernel, Microkernel, Hybrid Kernel, Nano Kernel, and Exo Kernel. The main functions of Kernel are memory management, resource management, and device management.
You can also read about layered structure of operating system.
Read about Batch Operating System here.
Recommended Topic - Memory hierarchy in computer network
Frequently Asked Questions
What is a Kernel?
A kernel is a computer program at the core of a computer's operating system. It generally has complete control over everything.
What are the types of Kernel?
Kernels are of five types: Monolithic Kernel, Microkernel, Hybrid Kernel, Nano Kernel, and Exo Kernel.
What are the main functions of Kernel?
The main functions of the Kernel are memory management, device management, and resource management.
Which type of Kernel is used by Windows?
Windows uses Hybrid Kernel as it combines the performance of a monolithic Kernel with the stability of a microkernel.
Which type of Kernel is used by Android?
Android Operating System, widely used in smartphones, is based on the Linux Kernel, which uses the monolithic type of Kernel.
Conclusion
We have extensively discussed Kernel in Operating systems in this article. We hope that this blog has helped you understand what Kernel is and what are its functionalities and types. You can refer to the below-given articles to enhance your knowledge of Operating Systems.
Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, Uber, Microsoft, etc. on Coding Ninjas Studio.
Also check out some of the Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, System Design, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.
Do upvote our blog to help other ninjas grow.
Happy Learning!!!