Recall that Belady’s anomaly is that the page-fault rate may increase as the…

2017

Recall that Belady’s anomaly is that the page-fault rate may increase as the number of allocated frames increases. Now, consider the following statements:

S1: Random page replacement algorithm (where a page chosen at random is replaced) suffers from Belady’s anomaly

S2: LRU page replacement algorithm suffers from Belady’s anomaly

Which of the following is CORRECT?

Answer: B. S1 is true, S2 is falseBelady’s anomaly: An algorithm suffers from Belady’s anomaly if there exists a reference string for which increasing the number of frames increases the number…

  1. A.

    S1 is true, S2 is true

  2. B.

    S1 is true, S2 is false

  3. C.

    S1 is false, S2 is true

  4. D.

    S1 is false, S2 is false

Attempted by 111 students.

Show answer & explanation

Correct answer: B

Belady’s anomaly: An algorithm suffers from Belady’s anomaly if there exists a reference string for which increasing the number of frames increases the number of page faults.

Key concept: Stack (inclusion) property — if at every time the set of pages held with k frames is always a subset of the set held with k+1 frames, then page faults cannot increase when frames increase.

  • LRU: LRU is a stack algorithm. With k frames it contains the k most recently used pages, and with k+1 frames those same k pages remain plus one more, so pages(k) ⊆ pages(k+1). Therefore LRU cannot exhibit Belady’s anomaly.

  • Random replacement: Random replacement is not a stack algorithm. Because evictions are chosen independently at random, the set of pages with k frames need not be a subset of the set with k+1 frames, so it can exhibit Belady’s anomaly for some reference strings.

Illustrative reference string: 1,2,3,4,1,2,5,1,2,3,4,5. For some runs of random replacement this string can produce more faults with 4 frames than with 3 frames (showing the anomaly), while LRU on the same string never increases faults when frames are increased.

Conclusion: S1 (Random replacement suffers from Belady’s anomaly) is true; S2 (LRU suffers from Belady’s anomaly) is false. The correct choice is the one that states S1 is true and S2 is false.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Wipro Preparation

Loading lesson…