GATE / CS ARCHIVE

GATE CSE 2012 / QUESTION 42

Compare FIFO, LRU and optimal page faults

Operating Systems · Virtual Memory & Paging · Full GATE CSE 2012 paper

GATE 2012, Q42 2 marks · MCQ
Report issue

Virtual Memory & Paging

Question 42, GATE 2012: Consider the virtual page reference string
             1, 2, 3, 2, 4, 1, 3, 2, 4, 1
        on a demand paged virtual memory system running on a computer system that has main memory
        size of 3 page frames which are initially empty. Let LRU, FIFO and OPTIMAL denote the number
        of page faults under the corresponding page replacement policy. Then
        (A) OPTIMAL < LRU < FIFO                                     (B) OPTIMAL < FIFO < LRU
        (C) OPTIMAL = LRU                                            (D) OPTIMAL = FIFO
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Step through it (3 policies)

Number the ten references from 1. FIFO faults at positions 1, 2, 3, 5, 6, 8: six faults. LRU faults at 1, 2, 3, 5, 6, 7, 8, 9, 10: nine faults. Optimal replacement faults at 1, 2, 3, 5, 8: five faults; at reference 5 evict page 2, whose next use is later than those of 1 and 3, and at reference 8 evict page 3, which is never used again. Thus OPTIMAL=5 < FIFO=6 < LRU=9, B.

Check: A hit updates recency in LRU but does not move a page in FIFO’s arrival order. This distinction first matters after reference 4, a hit on page 2: LRU remembers page 2 as recent, while FIFO still regards page 1 as the oldest arrival.

Original paper, page 10 · Answer key