The GATE Grind

GATE 2025 CS (CS1) – Question 54

Operating System · Memory Management and Virtual Memory · 2 marks · Numerical answer

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)

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 6

Explanation

Refs 1,3,2 fault (3). Ref 4 sees window 4,2,3,1 and evicts 1 (fault 4). Ref 1 sees 1,2,4,3 and evicts 3 (fault 5). Ref 3 sees 3,1,4 and evicts 2, which is not in the window (fault 6). The remaining refs hit, so there are 6 faults.