GateAI
Memory Management and Virtual Memory

GATE CSE 2025 Set 1 · Q54

NAT2 marksMedium

Time

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 4 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,4.1, 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)

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 6

Memory Management and Virtual Memory

We are given a sequence of 12 page references:

1,3,2,4,2,3,1,2,4,3,1,41, 3, 2, 4, 2, 3, 1, 2, 4, 3, 1, 4

with 3 initially empty frames.

When a page fault occurs, the OS inspects a lookahead window of up to 4 page references (the current page plus the next 3 future page references) and replaces the page in memory that will not be used for the longest time within this 4-page window.

Let's trace step-by-step:

  1. Ref 1: Frame state: {1}\{1\} →\rightarrow Page Fault (1)

  2. Ref 3: Frame state: {1,3}\{1, 3\} →\rightarrow Page Fault (2)

  3. Ref 2: Frame state: {1,3,2}\{1, 3, 2\} →\rightarrow Page Fault (3)

  4. Ref 4: Page fault occurs. Lookahead window (4 references starting from index 4): ⟨4,2,3,1⟩\langle 4, 2, 3, 1 \rangle.

    • Page 22 is accessed at index 5.

    • Page 33 is accessed at index 6.

    • Page 11 is accessed at index 7 (farthest in window).

    Therefore, page 11 is replaced with page 44. Frame state: {4,3,2}\{4, 3, 2\} →\rightarrow Page Fault (4)

  5. Ref 2: Page 22 is present →\rightarrow Hit (Frames: {4,3,2}\{4, 3, 2\})

  6. Ref 3: Page 33 is present →\rightarrow Hit (Frames: {4,3,2}\{4, 3, 2\})

  7. Ref 1: Page fault occurs. Lookahead window (4 references starting from index 7): ⟨1,2,4,3⟩\langle 1, 2, 4, 3 \rangle.

    • Page 22 is accessed at index 8.

    • Page 44 is accessed at index 9.

    • Page 33 is accessed at index 10 (farthest in window).

    Therefore, page 33 is replaced with page 11. Frame state: {4,1,2}\{4, 1, 2\} →\rightarrow Page Fault (5)

  8. Ref 2: Page 22 is present →\rightarrow Hit (Frames: {4,1,2}\{4, 1, 2\})

  9. Ref 4: Page 44 is present →\rightarrow Hit (Frames: {4,1,2}\{4, 1, 2\})

  10. Ref 3: Page fault occurs. Lookahead window (remaining references starting from index 10): ⟨3,1,4⟩\langle 3, 1, 4 \rangle.

    • Page 11 is accessed at index 11.

    • Page 44 is accessed at index 12.

    • Page 22 is not referenced at all within the window.

    Therefore, page 22 is replaced with page 33. Frame state: {4,1,3}\{4, 1, 3\} →\rightarrow Page Fault (6)

  11. Ref 1: Page 11 is present →\rightarrow Hit (Frames: {4,1,3}\{4, 1, 3\})

  12. Ref 4: Page 44 is present →\rightarrow Hit (Frames: {4,1,3}\{4, 1, 3\})

Total number of page faults =6= 6.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Memory Management and Virtual Memory previous year question is Q54 of the GATE CSE 2025 Set 1 paper. Find more GATE CSE PYQs on Memory Management and Virtual Memory in Operating Systems, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Memory Management and Virtual Memory PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Memory Management and Virtual Memory in GATE CSE

Memory Management and Virtual Memory has 32 GATE CSE PYQs across 22 papers from 2011 to 2026. 15 of them are 2-mark NAT questions like this one, and GATE CSE 2025 Set 1 has 2.

How GATE tests Memory Management and Virtual Memory

More from GATE CSE 2025 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2025 Set 1 · Q54 · NAT

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 4 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, 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)

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.