Tuesday, December 8, 2009

question in orkut community.....!!!!!

Assume tht a MM with only 4 pages ,each of 16 bytes,is initially empty.the cpu generates the following sequence of virtual addresses & uses the lru replacement policy.
0 ,4,8,20,24,36,44,12,68,72,80,28,32,88,92
How many page faults?Wht r the page no of the pages pages present in the MM at the end of the sequence.


solution:

Consider this figure....
Till the first 4 page requests come total page faults are 4....



Now consider that main memory is full with 4 pages...now any new page request makes the replacement policy...so we have to go for replacement algorithms...since here we use lru..the least used page would be replaced....since page 20 is been used very recently...than page 8 than page 4 than page 0...therefore page 0 is replaced with page 24 which is 5th page fault....hence till now the observation is

initial 5 unique numbers so number of page faults are 5 and last 4 pages are placed in the memory...

consider this figure...just showed page fault of page 24 then page 36 and then showed final page memory contents



so totally
page faults: 15
final contents of the memory 28 32 88 92