Wednesday 16 December 2015

Q38,P2j15 A LRU page replacement is used with four page frames and eight pages. How many page faults will occur with the reference string 0172327103. if the four frames are initially empty.

A) 6               B) 7                       C) 5                     D) 8.
Answer B.

Explanation.
LRU-
Whenever a page is used it is stamped with a counter value. When a page is to be replaced page with lowest stamp value is selected as the victim.

0172    3  2  7 1  0  3.
0(1 page fault,Counter=1),1(2 page fault,Counter=2),7(3 page fault,Counter=3),2 (4 page fault,Counter=4).
0 is selected as the victim .and replaced by.3. now frame is.

3(5 page fault,counter=5),1(2 page fault,Counter=2),7(3 page fault,Counter=3),2 (4 page fault,Counter=4)
 2 is already in the  frame  so counter is increased.
3(5 page fault,counter=5),1(2 page fault,Counter=2),7(3 page fault,Counter=3),2 (4 page fault,Counter=6)
7 is already in the frame so counter  is increased.
3(5 page fault,counter=5),1(2 page fault,Counter=2),7(3 page fault,Counter=7),2 (4 page fault,Counter=6)
1 is already in the frame so counter is increased.
3(5 page fault,counter=5),1(2 page fault,Counter=8),7(3 page fault,Counter=7),2 (4 page fault,Counter=6)
0 is not in the frame  so counter 5 is the least so 3 is replaced by 0.and page fault is increased.
0(6 page fault,counter=9),1(2 page fault,Counter=8),7(3 page fault,Counter=7),2 (4 page fault,Counter=6)
3 replaces 2
0(6 page fault,counter=9),1(2 page fault,Counter=8),7(3 page fault,Counter=7),3 (7 page fault,Counter=10)

3 comments:

Note: only a member of this blog may post a comment.