Context Switching and Indirect Scheduling Costs
Distinguish saved architectural state from the cache and translation effects that can persist after a scheduler dispatch.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Define the state required to resume a runnable thread
A context switch saves enough state to resume the interrupted execution, including the relevant registers and instruction position, then restores another thread’s state. A switch between separate address spaces can also select another set of address translations. Some processors tag cached translations by address space so valid entries can coexist under defined reuse conditions.
Lost locality can outweigh the direct save and restore
Two threads with disjoint hot working sets may evict each other’s cache lines. Migration to a different CPU can lose even more local state. This cost depends on access patterns, cache sizes and the scheduler’s placement, so a microbenchmark switching two small threads may not predict a larger workload. TLB locality explains translation reuse. Scheduler queues describe which running interval gives these working sets time to warm up.[1]