4.1.16 · D5Computer Architecture (Deep)
Question bank — Page replacement — FIFO, LRU, Clock, Optimal
These build directly on the definitions of FIFO, LRU, Clock, and Optimal (OPT) from the parent, plus ideas from Belady's Anomaly, Locality of Reference, and Virtual Memory & Paging.

True or false — justify
More frames always means fewer or equal page faults.
False for FIFO — this is Belady's Anomaly; a bigger queue can retain a "wrong" page and evict a needed one. True only for stack algorithms (LRU, OPT).
LRU and FIFO both evict "the oldest page," so they often disagree.
True — they do often disagree because "oldest" means different things: FIFO uses arrival time, LRU uses last-access time. A page loaded long ago but touched recently is old to FIFO, fresh to LRU.
Optimal (OPT) always produces strictly fewer faults than LRU.
False — OPT is a lower bound ( every policy), so it can tie. On
7 0 1 2 0 3 0 4 with 3 frames both score 6.Clock can never do worse than FIFO on any reference string.
False — the verdict fails because there exist strings where Clock's second-chance sparing keeps a page FIFO would have dropped, and that page then triggers extra faults later; Clock and FIFO are different policies with no ordering guarantee, so neither dominates the other. (In the degenerate case where no page ever earns a second chance, Clock merely matches FIFO — matching is not the same as never-worse.)
The cold-start (compulsory) faults are the same count for every policy at a fixed frame count.
True — the first reference to each distinct page must fault regardless of policy, since no policy can hold a page it has never seen. Only the later evictions differ.
A perfect (all-hit) run is achievable if the reference string touches more distinct pages than there are frames.
False — if distinct pages exceed frames, at minimum every distinct page's first touch faults, so some faults are unavoidable and a hit run is impossible.
LRU requires updating hardware state on every memory reference, not just on faults.
True — recency must be refreshed on every access (hit or miss), which is exactly why exact LRU is expensive and Clock exists as a cheap approximation.
Spot the error
"On a hit, FIFO moves the page to the newest position in its queue."
Error — FIFO never reorders on a hit; a hit changes nothing about age. Moving-to-newest-on-hit is LRU's behaviour, not FIFO's.
"Clock evicts the first page whose reference bit is 1."
Error — Clock evicts the first page it finds with . A page with gets its bit cleared and is spared (second chance), then the hand advances.
"OPT evicts the page used furthest in the past."
Error — that describes LRU. OPT looks forward and evicts the page whose next use is furthest in the future.
"Belady's Anomaly proves LRU can get worse with more frames."
Error — the anomaly is specific to FIFO (and non-stack policies). LRU is a stack algorithm and is immune.
"A page fault always requires evicting a victim."
Error — only when all frames are full. If a free frame exists, the page is simply inserted with no eviction.
"Fault rate = faults ÷ distinct pages referenced."
Error — the denominator is the total number of references, not distinct pages, because every reference is one hit-or-fault trial.
"Clock needs a timestamp per frame like LRU."
Error — Clock needs only one reference bit per frame; that single-bit cost is its whole selling point over LRU's timestamps.
Why questions
Why can FIFO evict a page and then immediately need it again?
Because FIFO's victim choice ignores usage entirely — it picks by arrival order, so a heavily-used but early-arriving page can be thrown out right before its next reference.
Why does LRU approximate OPT well in practice, but not in theory?
LRU bets that the recent past predicts the near future (Locality of Reference). This bet holds for real programs but can be defeated by adversarial or looping access patterns that violate temporal locality.
Why is OPT worth studying if it cannot be implemented?
It gives an unbeatable benchmark / lower bound — the fewest possible faults for a string and frame count — so you can measure how far a real policy is from perfect.
Why does the Clock hand clear to 0 instead of evicting on the first pass?
Clearing records "I checked you once"; a page truly in use will have its re-set to 1 by hardware before the hand returns, letting genuinely active pages survive while stale ones eventually meet the hand with .
Why are stack algorithms immune to Belady's Anomaly?
Because the set of pages held in frames is always a subset of the set held in frames; adding a frame can only add pages, never displace a page that would have been kept — so faults never go up as grows.
Why is minimizing page faults the whole objective, rather than minimizing evictions?
A single disk access costs roughly a RAM access; each avoided fault saves millions of cycles, so the cost is dominated by fault count, not by the bookkeeping of evictions.
Edge cases
If the number of frames equals or exceeds the number of distinct pages, how many faults occur?
Exactly the number of distinct pages (all compulsory cold-start faults). Once every page is loaded, nothing is ever evicted, so all four policies tie.
With exactly frames, what happens on every reference?
Every single reference is a fault — with no slots the page can never be resident, so there is nothing to keep and nothing to compare policies on; fault rate is for all of them.
With exactly frame, do FIFO, LRU, and OPT behave differently?
No — with one frame every fault evicts the only resident page, so all three make identical choices and produce identical fault counts.
What does Clock do if every frame's reference bit is 1 when a victim is needed?
The hand sweeps a full circle clearing all bits to 0, then evicts the page it started on — so a full loop of second chances collapses to picking the frame the hand first pointed at.
On a reference string with no repeats (all distinct pages), which policy wins?
None — every reference is a compulsory fault for all policies, so FIFO, LRU, Clock, and OPT all fault on every reference and tie.
Can OPT ever be forced to fault on a page that a smarter policy would have kept?
No — by definition OPT is optimal, so no policy can achieve fewer faults; any string that faults OPT faults every real policy at least as often.
What happens to page-fault behaviour as frames shrink toward zero relative to the working set?
Faults explode and the system spends most time swapping — this runaway state is thrashing, where too few frames hold too little of the active working set.
Recall Quick self-test
Name the one distinction that separates FIFO from LRU in a single word. ::: Time-basis — FIFO uses arrival, LRU uses last-access. Which two policies are provably anomaly-free? ::: LRU and OPT (both stack algorithms).