Context Switching

What is a context switch and why is it so expensive? A context switch is moving one process (thread) out of a processor and another process into the processor. This involves saving the process' and the processor's state. The process' state needs to be saved so that an accurate record of the process' execution point is maintained. The processor's state needs to be saved so that the processor can be put back into that state when the associated process continues its execution. Processor state is a component of a process' state, but not the whole story.

A process context is an operating system construct, and as such is very OS dependent. It is managed by a structure in the OS that contains the relevant aspects of a process' state, ...

Get Efficient C++ Performance Programming Techniques now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.