OS & Hardware
Why can a process context switch degrade performance more than the time spent saving and restoring registers would suggest?
- AThe CPU clock frequency drops on every switch
- BThe program is reloaded from disk on every switch
- CCache and TLB misses rise after the switch
Show answer and explanation
Answer: C. Cache and TLB misses rise after the switch
Saving and restoring registers is quick, but after the switch the caches and TLB hold the previous process's contents, so the new process misses until its data and translations are reloaded. On CPUs without ASIDs, the TLB must also be flushed when changing address spaces. This indirect cost can exceed the direct switching time. The clock does not slow down, and programs are not reloaded from disk.
- A. Switching does not lower the clock frequency.
- B. The program stays in memory and is not reloaded.
- C. Correct. It is the indirect cost of more cache and TLB misses.