Dual Mode of Operating Systems

By | September 9, 2020

Dual-mode operation forms the basis for I/O protection, memory protection and CPU protection. Two modes are provided by the hardware – user and kernel mode.

Mode bit is added to computer hardware to indicate the current mode. When system boots, hardware starts in kernel mode. The OS is loaded and then user process is started in user mode. When an interrupt occurs, hardware switches to kernel mode. When the OS gains control, its always the kernel mode and before passing control to user program, it switches the h/w to user mode.

Modes of Operating System :
In dual-mode operation, there are two separate modes: monitor mode (also called ‘system mode’ and ‘kernel mode’) and user mode.

1. User mode : a subset of instructions. Limited set of hardware and memory available.

  • I/O protection, all I/O operations are privileged; so user programs can only access I/O by sending a request to the (controlling) OS.
  • Memory protection, base/limit registers (in early systems), memory management unit, (MMU, in modern systems); so user programs can only access the memory that the OS has allocated.
  • CPU control, timer (alarm clock), context switch; so user programs can only read the time of day, and can only have as much CPU time as the OS allocates.

When a user application requests a service from the OS (via a system call), it must transition from user to kernel mode to fulfil the request. To switch from kernel mode to user mode, mode bit should be 1.

2. Kernel Mode :
When the system boots, hardware starts in kernel mode, then it start user application in user mode. We have privileged instructions which execute only in kernel mode, to provide protection to the hardware. If user attempt to run privileged instruction in user mode then it will treat instruction as illegal and traps to OS.

Some of the privileged instructions are:

  • Handling Interrupts
  • To switch from user mode to kernel mode.
  • Input-Output management.

To switch from user mode to kernel mode mode bit should be 0.



Please write comments if you find anything incorrect. A gentle request to share this topic on your social media profile.