The sustained performance of fast processors is critically dependent on cache performance. Cache performance in turn depends on locality of reference. When an operating system switches contexts, the assumption of locality may be violated because the instructions and data of the newly-scheduled process may no longer be in the cache(s). Context-switching thus has a cost above that associated with that of the operations performed by the kernel. We fed address traces of the processes running on a multi-tasking operating system through a cache simulator, to compute accurate cache-hit rates over short intervals. By marking the output of such a simulation whenever a context switch occurs, and then aggregating the postcontext-switch results of a large number of context switches, it is possible to estimate the cache performance reduction caused by a switch. Depending on cache parameters the net cost of a context switch appears to be in the thousands of cycies, or tens to hundreds of microseconds.
REF evaluated the impact of context switching on the Cycles Per Instruction (CPI) and cache miss rates for various cache parameters and found that the overheads for an average context switch could be up to tens to hundreds of microseconds.
The effect of context switches on cache performance
ASPLOS IV
Computer Science