Context switch.
also: context switches · context switchingThe OS saving one thread or process's CPU state and loading another's; frequent switches waste CPU time and caches.
the two-minute refresher
- The kernel saves registers, program counter and memory info for one task and restores another's.
- Direct cost is microseconds; the indirect cost is cold CPU caches and TLB.
- Thousands of busy threads mean constant switching: thread-per-connection does not scale far.
- Event loops and I/O multiplexing serve many connections with few threads.