OS & Hardware
In the clock (second-chance) page-replacement algorithm, what is each page's reference bit used for?
- ATo identify recently used pages and approximate LRU eviction cheaply
- BTo check whether a page was modified and decide whether to write it back
- CTo count how many processes use a page and evict the most shared first
Show answer and explanation
Answer: A. To identify recently used pages and approximate LRU eviction cheaply
Exact LRU requires updating an order on every access, which is costly with many pages. In the clock algorithm, hardware sets a page's reference bit to 1 when it is accessed; the OS sweeps pages like a clock hand, clearing a 1 to 0 and passing over the page (a second chance), and evicting a page whose bit is already 0. This keeps recently used pages and approximates LRU cheaply. Whether to write a page back is decided by the dirty bit.
- A. Correct. The reference bit identifies recent use for LRU-like replacement.
- B. The dirty bit decides whether to write back.
- C. It does not evict based on the number of processes.