What is Belady's anomaly?
MediumConceptPage Replacement & Thrashing
Answer
Belady's anomaly is the surprising case in which giving a process more page frames causes more page faults. It can happen with FIFO page replacement, but never with LRU or Optimal.
- FIFO evicts pages by when they were loaded, not by how they are used, so the set of pages it keeps with 4 frames is not always a superset of the set it keeps with 3 frames.
- LRU and Optimal are stack algorithms: the pages kept with n frames are always a subset of those kept with n + 1 frames, so extra frames can never add faults.
- The practical lesson: more memory does not guarantee fewer faults for every algorithm, which is one reason FIFO is rarely used on its own.
Example: reference string 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 under FIFO.
| Frames | Faults | References that hit |
|---|---|---|
| 3 | 9 | 1 and 2 (8th and 9th), 5 (12th) |
| 4 | 10 | 1 and 2 (5th and 6th) |
With 3 frames, the 5 at position 7 evicts 4 and keeps 1 and 2, which are needed next. With 4 frames, the same 5 evicts 1, the next 1 evicts 2, and every remaining reference faults in a chain.
More in Page Replacement & Thrashing
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Compare FIFO, LRU and Optimal page replacement. | Concept | Medium | Read the answer to Compare FIFO, LRU and Optimal page replacement. | |||
| 2 | What is Belady's anomaly? | Concept | Medium | Read the answer to What is Belady's anomaly? | |||
| 3 | Why is exact LRU expensive, and how does the clock algorithm approximate it? | Concept | Hard | Read the answer to Why is exact LRU expensive, and how does the clock algorithm approximate it? | |||
| 4 | What is thrashing, why does it happen, and how can it be prevented? | Concept | Hard | Read the answer to What is thrashing, why does it happen, and how can it be prevented? |