Context switch
Updated: 06/22/2024 by Computer Hope
A context switch occurs when a computer's CPU (Central Processing Unit) switches from one process or thread to a different process or thread.
Context switching allows a single CPU to handle numerous processes or threads without additional processors. Any operating system that allows multitasking relies heavily on context switching to allow different processes to run at the same time. There are three situations that a context switch is necessary, as shown below.
- Multitasking - When the CPU needs to switch processes in and out of memory so that more than one process can run.
- Kernel/User Switch - When switching between user mode to kernel mode, it may be used (but it isn't always necessary).
- Interrupts - When the CPU is interrupted to return data from a disk read.
Concurrency, CPU terms, Interrupt, Latency, Multithreading, Process control block, State, Thread