Professional Documents
Culture Documents
First in First Out (FIFO) - : Case 1: Number of Frames 3
First in First Out (FIFO) - : Case 1: Number of Frames 3
First in First Out (FIFO) - : Case 1: Number of Frames 3
This is the simplest page replacement algorithm. In this algorithm, the operating system
keeps track of all pages in the memory in a queue, the 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.
Request 0 1 5 3 0 1 4 0 1 5 3 4
Frame 3 5 5 5 1 1 1 1 1 3 3
Frame 2 1 1 1 0 0 0 0 0 5 5 5
Frame 1 0 0 0 3 3 3 4 4 4 4 4 4
Miss/Hi Mis Mis Mis Mis Mis Mis Mis Hi Hi Mis Mis Hi
t s s s s s s s t t s s t
Request 0 1 5 3 0 1 4 0 1 5 3 4
Frame 4 3 3 3 3 3 3 5 5 5
Frame 3 5 5 5 5 5 5 1 1 1 1
Frame 2 1 1 1 1 1 1 0 0 0 0 4
Frame 1 0 0 0 0 0 0 4 4 4 4 3 3
Miss/Hit Miss Miss Miss Miss Hit Hit Miss Miss Miss Miss Miss Miss
Therefore, in this example, the number of page faults is increasing by increasing the number
of frames hence this suffers from Belady's Anomaly.
-------------------------------------FIFO-----------------------------------------------------------------
2) Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 given Let's analyse the behaviour of
FIFO algorithm in two cases.
Case 1: Number of frames = 3
Case 2: Number of frames = 4
Answer : PF 9 /PF 10
3) A program has five virtual pages, numbered from 0 to 4. If the pages are referenced
in the order 012301401234, with three page frames, the total number of page faults
with FIFO will be equal to: ?
The Optimal will be 5, FIFO 6 and LRU 9. so, OPTIMAL < FIFO < LRU option (B) is
correct answer.
GATE-CS-2014 (Set-1)
Question -Assume that there are 3 page frames which are initially empty. If the page
reference string is 1, 2, 3, 4, 2, 1, 5, 3, 2, 4, 6, the number of page faults using the optimal
replacement policy is__________.
Solution- In optimal page replacement replacement policy, we replace the place which is not
used for longest duration in future.
Given three page frames.
Reference string is 1, 2, 3, 4, 2, 1, 5, 3, 2, 4, 6
Total page faults = 6 + 1 = 7
_______________________________________________________________________
GATE-CS-2007
A process has been allocated 3 page frames. Assume that none of the pages of the process are
available in the memory initially. The process makes the following sequence of page
references (reference string): 1, 2, 1, 3, 7, 4, 5, 6, 3, 1 If optimal page replacement policy is
used, how many page faults occur for the above reference string?
Optimal replacement policy looks forward in time to see which frame to replace on a page
fault. 1 23 -> 1,2,3 //page faults 173 ->7 143 ->4 153 -> 5 163 -> 6 Total=7 So Answer
is A . Page fault=7
GATE-CS-2014
Q- 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. Now the system uses
3 page frames for storing process pages in main memory. It uses the Least Recently Used
(LRU) page replacement policy.
Hence, total number of page faults are 6. Therefore, C is the answer.
--------------------------------------------------------------------------------------------------
Question: A system uses 4 page frames for storing process pages in main memory.
Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5. It uses the Least Recently Used (LRU) page
replacement policy. What is the total number of page faults ?
Answer- 8 page faults
1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 (Red marks are page fault)
---------------------------------------------------------------------------------------------------------------
Consider a virtual page reference string 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1
Suppose a demand paged virtual memory system running on a computer system such that the
main memory has 3 page frames. Then __________ page replacement algorithm has
minimum number of page faults.
Ans- Optimal
1. In FIFO algorithm 15 page fault will occur.