Belady’s Anomaly in Page Replacement

 

Belady’s Anomaly in Page Replacement

🔹 Definition

Belady’s Anomaly is a phenomenon where:

Increasing the number of page frames increases the number of page faults instead of decreasing them.

This behavior is unexpected, because normally adding more memory should reduce page faults.

Belady’s anomaly mainly occurs in:

  • FIFO page replacement

It does not occur in:

  • Optimal

  • LRU



Example Demonstrating Belady’s Anomaly

Reference String

1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

🔹 Case 1: 3 Page Frames (FIFO)

ReferenceFramesPage Fault
11-
21 2-
31 2 3Fault
42 3 4Fault
13 4 1Fault
24 1 2Fault
51 2 5Fault
11 2 5Hit
21 2 5Hit
32 5 3Fault
45 3 4Fault
55 3 4Hit

Total Page Faults = 9


🔹 Case 2: 4 Page Frames (FIFO)

ReferenceFramesPage Fault
11-
21 2-
31 2 3-
41 2 3 4Fault
11 2 3 4Hit
21 2 3 4Hit
52 3 4 5Fault
13 4 5 1Fault
24 5 1 2Fault
35 1 2 3Fault
41 2 3 4Fault
52 3 4 5Fault

Total Page Faults = 10


⚠️ Observation

FramesPage Faults
3 Frames9
4 Frames10

Even though we added more memory, the number of page faults increased.

This is Belady’s Anomaly.


Why It Happens

FIFO removes pages based only on arrival time, not usage.

A page that is heavily used may still be removed simply because it was loaded earlier.

Adding more frames changes the eviction order, sometimes causing more faults.


 Algorithms Affected

Algorithm    Belady’s Anomaly
FIFO    Yes
Random    Possible
LRU    No
Optimal    No
LFU    Rare

Key Takeaway

Belady’s Anomaly shows that:

Some page replacement algorithms behave counter-intuitively, where adding memory can worsen performance.

This is why modern systems prefer algorithms like LRU or its approximations.

Comments

Popular posts from this blog

Operating Systems OS PCCST403 Semester 4 BTech KTU CS 2024 Scheme

Introduction to Operating System -Virtualization, Concurrency, and Persistence

Operating Systems PCCST403 Scheme and Syllabus