A context switch happens when a running process gets interrupted by the operating system, in order to run another process.

Literally speaking, the operating system uses a process control block (PCB), which contains information about running processes. Typically, memory address spaces, program counter, and stack information are present on this block.

When one process is interrupted by another, the PCB for the first process is moved off the hardware cache, and replaced by the PCB for the second one. This finishes the context switch, and the new ‘running’ process can send requests to the operating system.

Now, onto whether it is good for you? The answer is NO!
This is an expensive operation, for two reasons:

  1. The one time swap of the process control block is relatively expensive
  2. Continuously cycling through processes moves PCB’s off the super fast hardware cache to slow read/write memory, or even the super slow disk.

More to come!