GATE | GATE-CS-2014-(Set-3) | Question 65
A system uses 3 page frames for storing process pages in 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
Explanation: What is a Page fault ? An interrupt that occurs when a program requests data that is not currently in real memory. The interrupt triggers the operating system to fetch the data from a virtual memory and load it into RAM.
Now, 4, 7, 6, 1, 7, 6, 1, 2, 7, 2 is the reference string, you can think of it as data requests made by a program.
Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.
Now the system uses 3 page frames for storing process pages in main memory. It uses the Least Recently Used (LRU) page replacement policy.
[ ] - Initially page frames are empty.i.e. no process pages in main memory. [ 4 ] - Now 4 is brought into 1st frame (1st page fault)
Explanation: Process page 4 was requested by the program, but it was not in the main memory(in form of page frames),which resulted in a page fault, after that process page 4 was brought in the main memory by the operating system.
[ 4 7 ] - Now 7 is brought into 2nd frame (2nd page fault) - Same explanation. [ 4 7 6 ] - Now 6 is brought into 3rd frame (3rd page fault) [ 1 7 6 ] - Now 1 is brought into 1st frame, as 1st frame was least recently used(4th page fault).
After this 7, 6 and 1 are were already present in the frames hence no replacements in pages.
[ 1 2 6 ] - Now 2 is brought into 2nd frame, as 2nd frame was least recently used(5th page fault). [ 1 2 7 ] -Now 7 is brought into 3rd frame, as 3rd frame was least recently used(6th page fault).
Hence, total number of page faults(also called pf) are 6. Therefore, C is the answer.
Quiz of this Question