Modes of Operating System

Operating system have different operating modes to fulfil the need to run the application, or compute a process as per user inputs. These modes define the level of access and privileges granted to execute tasks.

Kernel mode

A kernel is referred to as the heart of an operating system. It interacts with the hardware to compute the processes. A kernel is also the first component to load in an OS upon starting a machine.

Key points to remember: -

  1. Kernel mode is the most privileged mode in an operating system.
  2. In this mode, the operating system kernel has unrestricted access to all resources, including memory and I/O devices.
  3. The kernel can execute any CPU instruction.
  4. Kernel mode is responsible for critical system tasks such as memory management, process scheduling, and handling interrupts.
  5. If a process running in kernel mode encounters an error, it can crash the entire system.

User mode

All the application software runs in this mode, these applications don’t have privileged access to the underlying hardware, to execute them, to do so they have to interact with the Kernel.

E.g.: - Graphical User Interfaces and Command Line Interfaces.

Key points to remember: -

  1. User mode is a less privileged mode compared to kernel mode.
  2. Processes running in user mode have limited access to system resources and are restricted from performing sensitive operations directly.
  3. User-mode applications cannot access memory locations or execute instructions that could potentially harm the system.
  4. To access system resources or perform privileged operations, user mode processes must make system calls to the operating system kernel.
  5. If a process running in user mode encounters an error, it is isolated from other processes and cannot affect the entire system.

Mode switching

  • The CPU has a mode bit that indicates whether it is currently running in user mode (mode bit = 1) or kernel mode (mode bit = 0).
  • When a user mode process needs to perform an operation that requires kernel mode access, it makes a system call.
  • The operating system kernel handles the system call, switches the CPU to kernel mode, performs the requested operation, and then switches back to user mode before returning control to the calling process.
  • This mode-switching process involves saving the current context of the CPU, changing the mode bit, and loading the appropriate context for the new mode.