In the last lecture I explained you about what a kernel is. Today we gonna be looking at the kernel mode. So, let's get started:
The kernel mode is used by CPU when it wants to execute some privileged instructions. Privileged instructions are those instructions that could alter some parts of OS or some resources.
So,the operating system puts CPU in kernel mode whenever it wants to perform some privileged instruction. eg: whenever we boot-up the computer a program called the bootstrap program is load into the main memory by the kernel. This is a privileged instruction.
The OS puts CPU to user mode whenever a user is opening some application or working on some application. eg:some user working on excel or paint.
Types of Kernels
Kernel can be categorised into many types but among them 2 most important types are:
-> Monolithic Kernel
In this type of kernel the operating system runs as a single unit or as a single program in kernel mode. Monolithic Kernel runs entire OS(which includes device drivers, memory management, process management) in kernel mode.
Advantages of Monolithic Kernel
- A major advantage of Monolithic kernel is that it provides CPU scheduling , File Management, Memory Management through system calls.
- Single large process running entirely in a single address space.
- One major disadvantage is that if any service fails then it leads to entire system failure.
- If user wants to add some functionality then entire OS needs to be modified.
-> Microkernel
In a microkernel, user service and kernel service are implemented as different address space. The user services are present in user address space and kernel service are present at kernel address space.
Advantages of Microkernel
- In microkernel the debugging is easy because code is easy to understand.
- If a part fails then it won't affect other part of kernel.
- Since, it is micro it can perform small tasks.
- Inter-process communication is slow.