OS & Hardware
During a context switch, what must be saved for the process being switched out?
- AThe contents of the disk files the process is using
- BCPU execution state such as register values and the program counter
- CThe entire contents of the process's physical memory
Show answer and explanation
Answer: B. CPU execution state such as register values and the program counter
A context switch saves CPU state, such as general registers, the program counter, the stack pointer and the operating mode, so the process can later resume exactly where it left off, and loads the state of the next process. When switching processes, the register pointing to the page table is also switched. Memory and file contents remain in place, so they need not be saved on each switch.
- A. File contents remain on disk unchanged.
- B. Correct. The CPU state needed to resume is saved.
- C. Memory contents stay in place and are not saved on each switch.