• The ability to instruct the CPU to switch the task it is working on, so that each task can take turns to run - this is what powers Multi-tasking
  • Context switching relies on the Process Control Block (PCB) to store the task state, so when we resume the task, we don’t have to start from scratch; we can continue the task as if it never stopped
Switching SpeedMemory OverheadIsolation
Process Context SwitchSlowHigh
Thread Context SwitchFastLow

Process Context Switch

An expensive operation

Thread Context Switch

Low overhead

The Address Space and per-process items are remain unchanged when threads are switched within the same Process (进程). This avoids switching out the Memory Page which is an expensive operation.