FOR FREE YEAR SOLVED

GATE question on LRU:

 

GATE: 2014: SET-3: Q20:

A system uses 3 page frames for storing process pages in the main memory. It uses the Least Recently Used (LRU) page replacement policy. Assume that all the page frames are initially empty. What is the total number of page faults that will occur while processing the page reference string given below? 

4, 7, 6, 1, 7, 6, 1, 2, 7, 2

 

(A) 4       (B) 5          (C) 6           (D) 7

 

You should know:

Before seeing the solution please follow the previous chapter: 

LRU page replacement algorithm.

 

Solution and explanation:

Given page references: 4, 7, 6, 1, 7, 6, 1, 2, 7, 2.

 

 

Number of page faults is 6.

 

Shortcut method:

But in examination it is not possible to solve it by this elaborative way we can do it by a single frame like below:

Page references: 4, 7, 6, 1, 7, 6, 1, 2, 7, 2

 

 

The above process is a shortcut and the easiest process to calculate page faults.

 

So, the number of page faults = 6.