Skip to content
UniCircle
MediumNumericalVirtual memory

FIFO page replacement and Belady's anomaly

Question OS-108

For the page reference string 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5, count the page faults using FIFO replacement with 3 frames and with 4 frames. What does the result show?

Show hints

Trace the frames step by step; evict whichever page was loaded earliest.

Show the explanation

Worked answer. Frames start empty; FIFO evicts the oldest loaded page. F = fault, H = hit.

3 frames

Ref123412512345
Frames after11 21 2 32 3 43 4 14 1 21 2 51 2 51 2 52 5 35 3 45 3 4
ResultFFFFFFFHHFFH

Faults = 9.

4 frames

Ref123412512345
Frames after11 21 2 31 2 3 41 2 3 41 2 3 42 3 4 53 4 5 14 5 1 25 1 2 31 2 3 42 3 4 5
ResultFFFFHHFFFFFF

Faults = 10.

What it shows: Belady's anomaly. Giving FIFO more frames produced more faults (10 vs 9). FIFO evicts purely by load time, so the pages held with 4 frames are not always a superset of those held with 3.

Immune algorithms: stack algorithms, where pages kept with n frames are always a subset of those kept with n + 1, cannot show the anomaly. LRU and optimal (OPT) are stack algorithms.

Follow-up: "Why not use exact LRU?" Tracking the order of every access is too expensive; real systems approximate it with a reference bit, e.g. the clock (second-chance) algorithm.

Original UniCircle question. Last reviewed 28 Oct 2026.