- When an interrupt occurs, the system needs to save the current context of the process currently running on the CPU so that it can restore that context when its processing is done, essentially suspending the process and then resuming it.
- The context is represented in the PCB of the process; it includes
- the value of the CPU registers,
- the process state,
- and memory-management information.
- Switching the CPU to another process requires performing a state save of the current process and a state restore of a different process.
- This task is known as a context switch. When a context switch occurs, the kernel saves the context of the old process in its PCB and loads the saved context of the new process scheduled to run.
- process table keeps track of processes,
- context information stored in PCB,
- process suspended: register contents stored in PCB,
- process resumed: PCB contents loaded into registers
- Context-switch time is pure overhead, because the system does no useful work while switching. Context switching can be critical to performance.
Cem Ozdogan
2011-02-14