Open In App

GATE | GATE CS 2012 | Question 40

Consider the virtual page reference string
1, 2, 3, 2, 4, 1, 3, 2, 4, 1
On a demand paged virtual memory system running on a computer system that main memory size of 3 pages frames which are initially empty. Let LRU, FIFO and OPTIMAL denote the number of page faults under the corresponding page replacements policy. Then
(A) OPTIMAL (B) OPTIMAL (C) OPTIMAL = LRU
(D) OPTIMAL = FIFO

Answer: (B)
Explanation:
First In First Out (FIFO)
This is the simplest page replacement algorithm. In this algorithm, operating system keeps track of all pages in the memory in a queue; oldest page is in the front of the queue. When a page needs to be replaced page in the front of the queue is selected for removal.

Optimal Page replacement:

in this algorithm, pages are replaced which are not used for the longest duration of time in the future. Least Recently Used (LRU) In this algorithm page will be replaced which is least recently used.

Solution:



the virtual page reference string is 1, 2, 3, 2, 4, 1, 3, 2, 4, 1 size of main memory pages frames is 3.

For FIFO: total no of page faults are 6 (depicted in red)



For optimal: total no of page faults are 5 (depicted in red)

For LRU: total no of page faults are 9 (depicted in red)

The Optimal will be 5, FIFO 6 and LRU 9. so, OPTIMAL https://www.geeksforgeeks.org/operating-systems-set-5/amp/

This solution is contributed by Nitika Bansal
Quiz of this Question

Article Tags :