Context switch

Updated: 01/31/2019 by Computer Hope
Pair of switches toggled on and off

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.

CPU terms