Q2Operating System
Question
2 marks
Define Context Switching.
Answer
Context switching is the process of saving the state of a currently running process and restoring the state of the next process to be executed.
Context switching is the mechanism by which the CPU switches from one process (or thread) to another. The state (context) of the currently running process is saved into its Process Control Block (PCB), and the context of the next selected process is restored from its PCB. The context includes the program counter, CPU registers, stack pointer, and memory management information. Context switching is pure overhead — no useful work is done during the switch. The time taken depends on hardware support (e.g., register sets).