GOAL:
We’ll use the same page reference string with 3 frames and then 4 frames, and show that more frames cause more page faults — this is Belady’s Anomaly.
Page Reference String:
1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
Case 1: Using 3 Frames with FIFO
| Step | Reference | Frame State | Page Fault? |
|---|
| 1 | 1 | 1 _ _ | Yes |
| 2 | 2 | 1 2 _ | Yes |
| 3 | 3 | 1 2 3 | Yes |
| 4 | 4 | 2 3 4 | Yes |
| 5 | 1 | 3 4 1 | Yes |
| 6 | 2 | 4 1 2 | Yes |
| 7 | 5 | 1 2 5 | Yes |
| 8 | 1 | 1 2 5 | No |
| 9 | 2 | 1 2 5 | No |
| 10 | 3 | 2 5 3 | Yes |
| 11 | 4 | 5 3 4 | Yes |
| 12 | 5 | 3 4 5 | Yes |
Total Page Faults = 9
Case 2: Using 4 Frames with FIFO
| Step | Reference | Frame State | Page Fault? |
|---|
| 1 | 1 | 1 _ _ _ | Yes |
| 2 | 2 | 1 2 _ _ | Yes |
| 3 | 3 | 1 2 3 _ | Yes |
| 4 | 4 | 1 2 3 4 | Yes |
| 5 | 1 | 1 2 3 4 | No |
| 6 | 2 | 1 2 3 4 | No |
| 7 | 5 | 2 3 4 5 | Yes |
| 8 | 1 | 3 4 5 1 | Yes |
| 9 | 2 | 4 5 1 2 | Yes |
| 10 | 3 | 5 1 2 3 | Yes |
| 11 | 4 | 1 2 3 4 | Yes |
| 12 | 5 | 2 3 4 5 | Yes |
Total Page Faults = 10
Conclusion:
So, we increased memory but got more page faults — this is Belady’s Anamoly