Skip to content
Official PYQ · 2012

GATE CS 2012 Q42 — Memory Management and Virtual Memory

Explain with AI

Consider the virtual page reference string

1, 2, 3, 2, 4, 1, 3, 2, 4, 1\text{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  33 page frames which are initially empty. Let LRU\text{LRU}, FIFO\text{FIFO} and OPTIMAL\text{OPTIMAL} denote the number of page faults under the corresponding page replacement policy. Then

Choose one option
View worked solution

Answer: B

We are given the page reference string: 1, 2, 3, 2, 4, 1, 3, 2, 4, 1 with 33 initially empty page frames.

1. OPTIMAL Page Replacement
Replaces the page that will not be used for the longest period of time in the future.

  • 1 → [1] (Fault)
  • 2 → [1, 2] (Fault)
  • 3 → [1, 2, 3] (Fault)
  • 2 → [1, 2, 3] (Hit)
  • 4 → [1, 4, 3] (Fault) — 2 is replaced as its next reference is furthest
  • 1 → [1, 4, 3] (Hit)
  • 3 → [1, 4, 3] (Hit)
  • 2 → [1, 4, 2] (Fault) — 3 is replaced as it is not used again
  • 4 → [1, 4, 2] (Hit)
  • 1 → [1, 4, 2] (Hit)

Total OPTIMAL\text{OPTIMAL} faults = 55

2. FIFO Page Replacement
Replaces the oldest page in the memory.

  • 1, 2, 3 → [1, 2, 3] (3 Faults)
  • 2 → [1, 2, 3] (Hit)
  • 4 → [4, 2, 3] (Fault) — 1 replaced
  • 1 → [4, 1, 3] (Fault) — 2 replaced
  • 3 → [4, 1, 3] (Hit)
  • 2 → [4, 1, 2] (Fault) — 3 replaced
  • 4, 1 → [4, 1, 2] (2 Hits)

Total FIFO\text{FIFO} faults = 66

3. LRU Page Replacement
Replaces the page that has not been used for the longest period of time.

  • 1, 2, 3 → [1, 2, 3] (3 Faults)
  • 2 → [1, 3, 2] (Hit)
  • 4 → [4, 3, 2] (Fault) — 1 replaced
  • 1 → [4, 1, 2] (Fault) — 3 replaced
  • 3 → [4, 1, 3] (Fault) — 2 replaced
  • 2 → [2, 1, 3] (Fault) — 4 replaced
  • 4 → [2, 4, 3] (Fault) — 1 replaced
  • 1 → [2, 4, 1] (Fault) — 3 replaced

Total LRU\text{LRU} faults = 99

Comparing the page faults: 5<6<95 < 6 < 9, which gives OPTIMAL<FIFO<LRU\text{OPTIMAL} < \text{FIFO} < \text{LRU}.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Memory Management and Virtual Memory questions