Skip to content
Official PYQ · 2025

GATE CS 2025 Set 1 Q44 — Memory Management and Virtual Memory

Explain with AI
In optimal page replacement algorithm, information about all future page references is available to the operating system (OS). A modification of the optimal page replacement algorithm is as follows:

The OS correctly predicts only up to next 44 page references (including the current page) at the time of allocating a frame to a page.

A process accesses the pages in the following order of page numbers:
1,3,2,4,2,3,1,2,4,3,1,41,3,2,4,2,3,1,2,4,3,1,4
If the system has three memory frames that are initially empty, the number of page faults that will occur during execution of the process is __________. (Answer in integer)
View worked solution

Answer: 6:6

In the modified optimal page replacement algorithm, when a page fault occurs at time step tt, the OS only has visibility of the next 44 page references (from index tt to t+3t+3, inclusive). It replaces the page in the memory frames whose next reference in this lookahead window is furthest in the future. If a page in the frames is not referenced in this window, its next reference is treated as being at infinity.

Let the reference string be indexed from 11 to 1212:

Time (t)123456789101112Page132423124314\begin{array}{r|cccccccccccc} \text{Time } (t) & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\ \hline \text{Page} & 1 & 3 & 2 & 4 & 2 & 3 & 1 & 2 & 4 & 3 & 1 & 4 \end{array}

Let's trace the execution with 33 initially empty frames:

  1. t=1t = 1 (Page 1): Page fault. Frames: {1}\{1\}
  2. t=2t = 2 (Page 3): Page fault. Frames: {1,3}\{1, 3\}
  3. t=3t = 3 (Page 2): Page fault. Frames: {1,3,2}\{1, 3, 2\}
  4. t=4t = 4 (Page 4): Page fault.
    • Lookahead window (indices 44 to 77): [4,2,3,1][4, 2, 3, 1]
    • Next references of current pages: 22 is at t=5t=5, 33 is at t=6t=6, and 11 is at t=7t=7.
    • Since 11 is furthest, we replace 11 with 44.
    • Frames: {4,3,2}\{4, 3, 2\}
  5. t=5t = 5 (Page 2): Hit. Frames: {4,3,2}\{4, 3, 2\}
  6. t=6t = 6 (Page 3): Hit. Frames: {4,3,2}\{4, 3, 2\}
  7. t=7t = 7 (Page 1): Page fault.
    • Lookahead window (indices 77 to 1010): [1,2,4,3][1, 2, 4, 3]
    • Next references of current pages: 22 is at t=8t=8, 44 is at t=9t=9, and 33 is at t=10t=10.
    • Since 33 is furthest, we replace 33 with 11.
    • Frames: {4,1,2}\{4, 1, 2\}
  8. t=8t = 8 (Page 2): Hit. Frames: {4,1,2}\{4, 1, 2\}
  9. t=9t = 9 (Page 4): Hit. Frames: {4,1,2}\{4, 1, 2\}
  10. t=10t = 10 (Page 3): Page fault.
    • Lookahead window (indices 1010 to 1212): [3,1,4][3, 1, 4]
    • Next references of current pages: 11 is at t=11t=11, 44 is at t=12t=12, and 22 is not in the window (infinity).
    • Since 22 is not in the window, we replace 22 with 33.
    • Frames: {4,1,3}\{4, 1, 3\}
  11. t=11t = 11 (Page 1): Hit. Frames: {4,1,3}\{4, 1, 3\}
  12. t=12t = 12 (Page 4): Hit. Frames: {4,1,3}\{4, 1, 3\}

The total number of page faults that occur during execution is 6.

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

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