operating-systems

Definition

Mode Switch

A mode switch is the atomic hardware transition of the CPU privilege level between User Mode and Kernel Mode. It allows the OS to regain control of the processor.

Triggers

Supervisor Call

Explicit request from a user program for an OS service.

Trap

Exception triggered by current instruction (e.g., division by zero, invalid memory access).

Interrupt

Signal from external source (hardware timer, I/O device).

Mode Switch vs. Process Switch

Mode Switch

Lightweight operation saving only enough state (PC, registers) to handle the kernel event. CPU remains in the same process context.

Process Switch

Heavyweight operation requiring PCB update, address space switch, and potential TLB flush. Requires a mode switch as prerequisite.

Performance

Mode switching is significantly faster than process switching as it does not change memory management context or affect caches.