retagged by
918 views
0 votes
0 votes

Determine the number of page faults when references to pages occur in the following order: $1,2,4,5,2,1,2,4$. Assume that the main memory can accommodate $3$ pages and the main memory already has the pages $1$ and $2$, with page $1$ having been brought earlier than page $2$.(LRU algorithm is used).

  1. $3$
  2. $5$
  3. $4$
  4. None of these.
retagged by

2 Answers

2 votes
2 votes

Least Recently Used –
In this algorithm page will be replaced which is least recently used.

 

     1
     2
    

1).now  1 is already in memory so 1 hit

2.)now  2 is already in memory so 2 hit

3.)now  4 is not  in memory so  miss-FIRST page faults

    1
    2
    4

4.)now  5 is not  in memory so miss according to LRU we replace with 1-SECOND page faults

    5
    2
    4

5.)now  2 is already in memory so hit

6.)now  1 is not  in memory so  miss and we replace with 4 number page accordingly LRU-THIRD page faults

    5
    2
    1

7.)now  2 is already in memory so 2 hit

8.)now  4 is not  in memory so miss according to LRU we replace with 5-FOURTH page faults

    4
    2
    1

total number of page faults = 4

 

Answer:

Related questions

2 votes
2 votes
1 answer
3
3 votes
3 votes
1 answer
4
Sona Barman asked Jan 18, 2018
458 views
Self doubt:What is the rule or keyb point we should keep in mind while solving problems on LRU page replacement algorithm? Please explain with examples.