Course contentsShow
← Computer Science
Lesson 1204 of 2,87228. Operating Systems FundamentalsFree lesson

User Mode vs Kernel Mode

Understand the privilege separation between user mode and kernel mode, and why this boundary exists for system security.

User Mode vs Kernel Mode

What you'll learn: How operating systems use two privilege levels to protect the system from accidental or malicious damage.

The Privilege Boundary

Modern processors run in two distinct modes: user mode and kernel mode. This separation is a fundamental security mechanism built into the CPU hardware itself.

When your application runs—whether it's a web browser, game, or text editor—it executes in user mode. In this mode, the program has restricted access to system resources. It cannot directly touch hardware, modify critical memory, or execute privileged instructions.

When the OS kernel executes, it runs in kernel mode. Here, the code has unrestricted access to everything: all memory, all hardware devices, and all CPU instructions. This is where system calls are actually fulfilled.

Why This Boundary Exists

Think of it like building access levels: regular employees (user programs) can only enter certain rooms, while security personnel (the kernel) can access every area, including the server room and security systems.

Without this separation, any program could:

  • Crash the entire system by corrupting kernel memory
  • Read passwords from other programs
  • Disable security features
  • Take complete control of the machine

The mode bit in the CPU's status register tracks which mode is active. When a system call happens, the CPU switches from user mode to kernel mode, executes the privileged operation safely, then switches back.

This context switch has a small performance cost, but it's essential: it ensures only trusted, carefully-written kernel code can perform dangerous operations.

Key Takeaway: User mode restricts programs to safe operations, while kernel mode grants full system access—this privilege separation is the foundation of OS security and stability.