User Mode vs Kernel Mode: Key Differences Explained
A CPU has a user mode, in which applications run, and a kernel mode (privileged mode), in which the OS kernel runs. In user mode, privileged instructions such as setting up page tables, performing I/O operations and disabling interrupts cannot be executed, and only the memory of the process itself can be accessed. When something like reading or writing a file is needed, the program asks the kernel through a system call. This keeps a bug or malicious behavior in one application from affecting other processes, the OS or the hardware.
| Aspect | User mode | Kernel mode |
|---|---|---|
| Programs that run | Applications | The OS kernel and most device drivers |
| Executable instructions | Ordinary instructions only. Executing a privileged instruction raises an exception | All instructions, including switching page tables, enabling and disabling interrupts, and setting control registers |
| Accessible memory | Only the pages permitted to the user in the process's own virtual address space | Everything, including the kernel area. Can also handle physical memory and device registers |
| Device operations | Not directly. Asks the kernel through system calls | Reads and writes registers directly and handles interrupts |
| Names in architectures (examples) | x86 ring 3, Arm EL0, RISC-V U-mode | x86 ring 0, Arm EL1, RISC-V S-mode |
| What triggers a mode switch | Entry into kernel mode on system-call instructions (syscall, svc, ecall, etc.), device or timer interrupts, and exceptions (page faults, division by zero, illegal instructions, etc.) | A dedicated return instruction (sret, eret, etc.) restores the return address and mode at the same time, returning to user mode |
| Switching cost (typical) | A system-call round trip takes roughly 100 ns to 1 µs. Vulnerability mitigations can increase it | Work within the kernel uses function calls, with no mode switch. Switching processes (a context switch) is heavier still |
| Impact of bugs | Only that process is forcibly terminated | The whole system can stop (kernel panic, etc.) |
Figures are typical orders of magnitude and vary by process generation and product.