Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Differentiate between process switch and mode switch in OS
A process is defined as a program in execution and an entity that represents the basic unit of work to be implemented in the system. Understanding the difference between process switch and mode switch is crucial for comprehending how operating systems manage CPU resources and maintain system security.
Process Switch
A process switch (also called context switch) occurs when the processor switches from one thread/process to another thread or process. It involves saving the contents of CPU registers and instruction pointer for the current process.
For the new task, the registers and instruction pointer are loaded into the processor, then execution of the new process may start or resume. The old program will not execute further, but its state is saved in memory so the kernel can resume it later when ready.
Features of Process Switch
Affects system performance due to overhead
Increases load on CPU processor
Requires saving and restoring complete process context
Enables multitasking by time-sharing the CPU
Triggered by scheduler or interrupts
Mode Switch
A mode switch occurs when the CPU changes privilege levels between user mode and kernel mode. The kernel operates at a higher privilege level than standard user tasks to maintain system security and resource control.
During a mode switch, the currently executing process does NOT change. The processor uses different modes to protect the OS from misbehaving programs and control access to system resources like RAM and I/O devices.
Steps for Mode Switch
Program execution starts in user mode with limited privileges
When system resources are needed, a mode switch to kernel mode occurs
Mode switch happens through system calls or hardware interrupts
Kernel functions execute with full system access
After completion, system returns to user mode
Note − A general protection fault occurs when a user application attempts unauthorized actions, such as accessing restricted memory areas.
Comparison
| Aspect | Process Switch | Mode Switch |
|---|---|---|
| Definition | Switch between different processes | Switch between privilege levels |
| Process Identity | Changes (Process A ? Process B) | Remains same process |
| Overhead | High (save/restore full context) | Low (minimal state change) |
| Trigger | Scheduler, time slice expiry | System calls, interrupts |
| Purpose | Multitasking, resource sharing | System security, privilege control |
Conclusion
Process switch changes the executing process entirely with high overhead, while mode switch only changes privilege levels within the same process. A mode switch is often required before a process switch can occur, as only the kernel has the authority to perform context switching between processes.
