Definition
User Mode
User Mode is a restricted execution state of the processor designed for executing untrusted application code. In this mode, the CPU is prohibited from executing privileged instructions or accessing memory outside of the process’s allocated user space.
Properties
Restrictions
Code running in User Mode cannot:
- Access kernel space memory.
- Manipulate hardware registers directly (e.g., control registers).
- Execute privileged instructions (any attempt to do so generates a trap/exception).
Transition
To perform privileged operations (like I/O or memory allocation), a process must transition to Kernel Mode via controlled entry points:
- System Calls: Explicit requests by the program.
- Interrupts: Asynchronous hardware signals.
- Traps: Synchronous exceptions (e.g., division by zero).
User vs. Kernel Mode
| Feature | User Mode | Kernel Mode |
|---|---|---|
| Privilege Level | Low (Restricted) | High (Unrestricted) |
| Hardware Access | Through the OS only | Direct and full access |
| Memory Access | Allocated user space only | All system memory |
| Failure Impact | Process crash only | Potential system crash |