Two types of mode in OS, User Mode, and Kernal Mode | Operating System EP-10

Two types of mode in OS, User Mode, and Kernal Mode | Operating System EP-10

  • In this article, I am going to explain to you about User Mode and Kernel Mode in an operating system.

  • The below diagram will help you to understand the user mode and kernel mode, and give a better picture of these two modes in the operating system.

usermode.png

  • Whenever we use an application at that time by default we are in user mode.

  • All the core functionalities and drivers work in kernel mode.

  • The process gets switched in between two modes i.e. user mode and kernel mode.

  • Operating system works at kernel mode.

  • Suppose we are writing a C program, and in that program suppose it is written that you have to read a file and have to write something in that file.

  • Remember one thing that the file is stored on Hard Disk and the hard disk is hardware and all the hardware is in control of the kernel. So a user cannot directly access the hardware it has to take the help of the kernel.

  • To read that file we have to use a system call. A system call is a way by which we can access the kernel. We will use the read() system call, which means that we want to read some data from any file.

  • After it, the process gets shifted from user mode to kernel mode.

  • Now, we will read the file as we are now in kernel mode. All the operations of read and write will be completed here.

  • After that, the process will get shifted to user mode again. The process has to shift to user mode because we the user are working in user mode.

kernalmode.jpg