Question

Consider a main memory with five page frames and the following sequence of page references: 3,8,2,3,9,1,6,3,8,9,3,6,2,1,33, 8, 2, 3, 9, 1, 6, 3, 8, 9, 3, 6, 2, 1, 3. Which one of the following is true with respect to page replacement policies First In First Out (FIFO) and Least Recently Used (LRU)?

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2015 answer key

Solution

Simulate FIFO and LRU page replacement policies step by step over the 15-page reference string with 5 frames.

Given 5 frames and page references: 3,8,2,3,9,1,6,3,8,9,3,6,2,1,33, 8, 2, 3, 9, 1, 6, 3, 8, 9, 3, 6, 2, 1, 3.

  1. FIFO Simulation:

    • Ref 3: [3] -> Fault 1
    • Ref 8: [3, 8] -> Fault 2
    • Ref 2: [3, 8, 2] -> Fault 3
    • Ref 3: [3, 8, 2] -> Hit
    • Ref 9: [3, 8, 2, 9] -> Fault 4
    • Ref 1: [3, 8, 2, 9, 1] -> Fault 5 (frames full)
    • Ref 6: Replace oldest (3) -> [6, 8, 2, 9, 1] -> Fault 6
    • Ref 3: Replace oldest (8) -> [6, 3, 2, 9, 1] -> Fault 7
    • Ref 8: Replace oldest (2) -> [6, 3, 8, 9, 1] -> Fault 8
    • Ref 9: Hit
    • Ref 3: Hit
    • Ref 6: Hit
    • Ref 2: Replace oldest (9) -> [6, 3, 8, 2, 1] -> Fault 9
    • Ref 1: Hit
    • Ref 3: Hit
      Total FIFO faults = 99.
  2. LRU Simulation:

    • Ref 3: [3] -> Fault 1
    • Ref 8: [3, 8] -> Fault 2
    • Ref 2: [3, 8, 2] -> Fault 3
    • Ref 3: [8, 2, 3] -> Hit
    • Ref 9: [8, 2, 3, 9] -> Fault 4
    • Ref 1: [8, 2, 3, 9, 1] -> Fault 5
    • Ref 6: LRU is 8, replace with 6 -> [2, 3, 9, 1, 6] -> Fault 6
    • Ref 3: [2, 9, 1, 6, 3] -> Hit
    • Ref 8: LRU is 2, replace with 8 -> [9, 1, 6, 3, 8] -> Fault 7
    • Ref 9: [1, 6, 3, 8, 9] -> Hit
    • Ref 3: [1, 6, 8, 9, 3] -> Hit
    • Ref 6: [1, 8, 9, 3, 6] -> Hit
    • Ref 2: LRU is 1, replace with 2 -> [8, 9, 3, 6, 2] -> Fault 8
    • Ref 1: LRU is 8, replace with 1 -> [9, 3, 6, 2, 1] -> Fault 9
    • Ref 3: [9, 6, 2, 1, 3] -> Hit
      Total LRU faults = 99.

Both policies incur the same number of page faults (99). This corresponds to option A.

Final answer

A

Common trap

Assuming LRU must strictly outperform FIFO on any reference sequence.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2015 Computer Science and Information Technology (CS) Session 1
Question
57 of 65, printed as CS Q.47
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.