Open In App

GATE | GATE CS 2012 | Question 40

Like Article
Like
Save
Share
Report

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 < LRU < FIFO (B) OPTIMAL < FIFO < LRU (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)
nitika_42

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

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

The Optimal will be 5, FIFO 6 and LRU 9. so, OPTIMAL < FIFO < LRU option (B) is correct answer. See https://www.geeksforgeeks.org/operating-systems-set-5/

This solution is contributed by Nitika Bansal

Quiz of this Question


Last Updated : 14 Feb, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads