User mode and Kernel mode, ,Mode bit in Operating Systems (OS)

User mode and Kernel mode bit (OS), How to know, How to change/switch

In this tutorial, we will learn about the followings;

  1. What is user mode?
  2. What is kernel mode?
  3. How to know that a system is in user mode or kernel mode?
  4. How to change the User and Kernel mode bit?

There are two very famous modes of OS. One is user mode and another one is kernel mode. Mode bit is a bit that indicates current mode of execution.  This mode bit is stored in a register called Program Status Word (PSW) register. If someone wants to know about that system is in which mode, then it can be seen in PSW register.

What is user mode?

When a task is executing on the system on behalf of the user application, then the system is in user mode.

What is kernel mode?

The user can request a service by using the user application. When a user application requests a service from the OS through systems call, then the system needs to switch from the user mode to the kernel mode.  When a system call is done, then the system again switched from kernel mode to the user mode.

How to know that a system is in user mode or kernel mode?

If we want to know the mode of OS, then we need to know the value of mode bit. Mode bit value 0 indicated that the system is in kernel mode and 1 indicates that the system is in the user mode.

How to change the User and Kernel mode bit?

The mode bit can be changed by some events;

For example, when a user makes a system call to an OS, the mode bit is set from 1 to 0. Here 1 to 0 means that after a system call, the system mode is changed from the User mode to the Kernal mode.

When we ON the computer, the system is in kernel mode. When we run the user application, the system is in user mode.

In case of hardware and software generated interrupts, the system changes its state from user mode to the kernel mode.