- 2072 Magh · 2+8 marks
Page faults: LRU, FIFO, Optimum
Short answer
A page fault is a trap when a page is not in memory. With three frames, LRU causes 15 faults, FIFO 16, and Optimal 11.
What is page fault? Consider the following page reference string: 1,2,3,4,2,1,5,6,2,1,2,3,7,6,3,2,1,2,3,6. How many page faults would occur in LRU, FIFO and Optimum replacement algorithm?
Page fault
A page fault is a trap raised when a process refers to a page that is not in main memory. The OS reads the page from disk into a free frame (using a replacement algorithm if no frame is free) and restarts the instruction.
Simulation
Reference string: 1,2,3,4,2,1,5,6,2,1,2,3,7,6,3,2,1,2,3,6 (20 references). The number of frames is not stated; three frames are assumed (all initially empty). * = fault.
LRU
ref 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
F1 1 1 1 4 4 4 5 5 5 1 1 1 7 7 7 2 2 2 2 2
F2 - 2 2 2 2 2 2 6 6 6 6 3 3 3 3 3 3 3 3 3
F3 - - 3 3 3 1 1 1 2 2 2 2 2 6 6 6 1 1 1 6
* * * * * * * * * * * * * * *
Faults = 15.
FIFO
ref 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
F1 1 1 1 4 4 4 4 6 6 6 6 3 3 3 3 2 2 2 2 6
F2 - 2 2 2 2 1 1 1 2 2 2 2 7 7 7 7 1 1 1 1
F3 - - 3 3 3 3 5 5 5 1 1 1 1 6 6 6 6 6 3 3
* * * * * * * * * * * * * * * *
Faults = 16.
Optimum
ref 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
F1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 6
F2 - 2 2 2 2 2 2 2 2 2 2 2 7 7 7 2 2 2 2 2
F3 - - 3 4 4 4 5 6 6 6 6 6 6 6 6 6 1 1 1 1
* * * * * * * * * * *
Faults = 11.
Result
| Frames | LRU | FIFO | Optimum |
|---|---|---|---|
| 3 (assumed) | 15 | 16 | 11 |
| 4 | 10 | 14 | 8 |
| 5 | 8 | 10 | 7 |
Answer (3 frames): LRU = 15, FIFO = 16, Optimum = 11 page faults. Optimum is always the lowest; with more frames faults reduce.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Page faults: FIFO, Optimal, LFU, LRU · Operating System, chapter 4 · asked 2×
- Page faults with 3 frames: LRU, FIFO, OPT · Operating System, chapter 4 · asked 2×
- LRU algorithm; page faults on string · Operating System, chapter 4
- Hits and faults: FIFO, LRU, Optimal · Operating System, chapter 4
- Thrashing; page faults on 3 frames · Operating System, chapter 4
- Page fault; allocation and replacement · Operating System, chapter 4
- LRU replacement with hit and miss · Computer Organization and Architecture, chapter 6