in Operating System edited by
6,537 views
16 votes
16 votes

A process, has been allocated $3$ page frames. Assume that none of the pages of the process are available in the memory initially. The process makes the following sequence of page references (reference string): $1, 2, 1, 3, 7, 4, 5, 6, 3, 1$

Least Recently Used (LRU) page replacement policy is a practical approximation to optimal page replacement. For the above reference string, how many more page faults occur with LRU than with the optimal page replacement policy?

  1. $0$
  2. $1$
  3. $2$
  4. $3$
in Operating System edited by
6.5k views

2 Comments

In full length test it is showing option b as a correct answer. So, please correct it.
1
1
Note that rest of the faults will we first acces fault (as in optimal), extra faults will be for reference to 1 and 3 at the end.
0
0

4 Answers

19 votes
19 votes
Best answer

Using $LRU = 9$ Page Fault

Using Optimal$ = 7$ Page Fault

So, LRU-OPTIMAL $=2$

Option (C).

edited by

1 comment

option C).
3
3
12 votes
12 votes
Optimal replacement policy

1     1      1     1     1

2      7      4     5     6

3      3      3     3     3

 For Pages 1 2 3 6 4 5  6, page faults occur

LRU replacement policy

9 page faults occur page fault occurs for pages 1 2 3 7 4 5 6 3 1

So 2 more page faults than optimal algorithm

So the answer is $(C)$
edited by
1 vote
1 vote

Solution to the above problem.

Tip: In question asking no. of page fault always calculate no. of  page hit as its count will be less so keeping a track on its count will be easy.

No. of Page fault =Total length of reference string - No. of Page Hit

0 votes
0 votes

Optimal: 7 page faults. https://gateoverflow.in/1274/gate2007-82?show=334037#a334037

LRU: 9 page faults

1 2 1 3 7 4 5 6 3 1
      3 3 3 5 5 5 1
  2 2 2 7 7 7 6 6 6
1 1 1 1 1 4 4 4 3 3
F F $\times$ F F F F F F F

 $Ans: 9-7=2$

Answer:

Related questions