Context switching is the process by which the operating system saves the state of a currently running process and loads the state of another process. This allows multiple processes to share a single CPU efficiently, giving the illusion of parallelism in a time-shared system.

  • When a CPU switches to another process, the system must save the state of the old process and load the saved state for the new process via a context switch
  • Context of a process represented in the PCB
  • Context-switch time is overhead; the system does no useful work while switching
  • Time dependent on hardware support