Questions: Context Switching and CPU Dispatch

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

After a context switch from process A to process B, process B's first several memory accesses are unusually slow. The most likely cause is:

AThe dispatcher incorrectly saved process A's registers into process B's PCB
BSwitching address spaces flushed the TLB, forcing full page table lookups for each of process B's memory accesses
CProcess B's program counter was set to a wrong instruction during the dispatch
DProcess B's data had to be reloaded from disk rather than from RAM
Question 2 Multiple Choice

An OS designer is choosing between very short time slices (frequent context switching) and longer time slices (infrequent context switching). Which best captures the core tradeoff?

AShort time slices give better responsiveness to interactive processes but waste CPU time on context switch overhead; longer time slices reduce overhead but hurt responsiveness
BShort time slices reduce TLB misses by keeping each process's address translations warm; longer time slices cause more TLB invalidation
CLonger time slices always produce better total throughput regardless of workload type
DThe tradeoff is irrelevant because modern CPUs perform context switches in nanoseconds with no measurable overhead
Question 3 True / False

Switching between two threads within the same process is cheaper than switching between two separate processes, because threads share the same address space and no TLB flush is required.

TTrue
FFalse
Question 4 True / False

The primary cost of a context switch is the time taken to save and restore CPU registers, which typically takes several milliseconds on modern hardware.

TTrue
FFalse
Question 5 Short Answer

Why is a context switch between two threads in the same process cheaper than a context switch between two separate processes, even though both require saving and restoring CPU registers?

Think about your answer, then reveal below.