Page Replacement Algorithm
Page Replacement Algorithm
MENU
IS T
Page replacement algorithms
REplacement
algorithms
Page Replacement Algorithms in Operating
Systems (OS)
by : abhishek
ANALYS CONTAC Page replacement
MENU
IS T algorithms
1. Page replacement is needed in the operating systems that use virtual memory
using Demand Paging. As we know in Demand paging, only a set of pages
of a process is loaded into the memory. This is done so that we can have
more processes in the memory at the same time.
2. When a page that is residing in virtual memory is requested by a process for
its execution, the Operating System needs to decide which page will be
replaced by this requested page. This process is known as page replacement
and is a vital component in virtual memory management.
ANALYS CONTAC
MENU
IS T
Type replacement
algorithms
• Optimal Page
Replacement Algorithm
01
algorithm
01 If the page to be searched is found among the frames then, this process is
known as Page Hit.
If the page to be searched is not found among the frames then, this process is
known as Page Fault.
When Page Fault occurs this problem arises, then the First In First Out Page
Replacement Algorithm comes into picture.
The First In First Out (FIFO) Page Replacement Algorithm removes the
Page in the frame which is allotted long back. This means the useless page
which is in the frame for a longer time is removed and the new page which is
in the ready queue and is ready to occupy the frame is allowed by the First In
First Out Page Replacement.
ANALYS CONTAC Page replacement
MENU
IS T algorithms
Example :
Consider the reference string 7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1
for a memory with three frames and calculate number of page faults by using
FIFO (First In First Out) Page replacement algorithms.
Points to Remember
Page Not Found - - - > Page Fault
Page Found - - - > Page Hit
Reference String:
ANALYS CONTAC Page replacement
MENU
IS T algorithms
Example :
Number of Page Hits = 5 The Ratio of Page Hit to the Page Fault = 5 : 15 - - - > 1: 3 - - -
Number of Page Faults = 15 >0.33
Belady’s ANOMALY
In the case of LRU and optimal page replacement algorithms, it is seen that
the number of page faults will be reduced if we increase the number of
frames. However, Balady found that, In FIFO page replacement algorithm,
the number of page faults will get increased with the increment in number of
frames.
This is the strange behavior shown by FIFO algorithm in some of the cases.
This is an Anomaly called as Belady'sAnomaly.
Number of Page Hits = 2 Therefore, in this example, the number of page faults is
Number of Page Faults = 10 increasing by increasing the number of frames hence this suffers
from Belady'sAnomaly.
ANALYS CONTAC Page replacement
MENU
IS T algorithms
02 If the page to be searched is not found among the frames then, this process is
known as Page Fault.
When Page Fault occurs this problem arises, then the OPTIMAL Page
Replacement Algorithm comes into picture.
The OPTIMAL Page Replacement Algorithms works on a certain principle.
The principle is:
Replace the Page which is not used in the Longest Dimension of time in
future
This principle means that after all the frames are filled then, see the future
pages which are to occupy the frames. Go on checking for the pages which
are already available in the frames. Choose the page which is at last.
ANALYS CONTAC Page replacement
MENU
IS T algorithms
Example :
Consider the reference string 7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1
for a memory with three frames and calculate number of page faults by using
OPTIMAL Page replacement algorithms.
Points to Remember
Page Not Found - - - > Page Fault
Page Found - - - > Page Hit
Reference String:
ANALYS CONTAC Page replacement
MENU
IS T algorithms
Example :
Number of Page Hits = 12 The Ratio of Page Hit to the Page Fault = 12 : 8 - - - > 3 : 2 - - - >
Number of Page Faults = 8 1.5
03 If the page to be searched is found among the frames then, this process is
known as Page Hit.
If the page to be searched is not found among the frames then, this process is
known as Page Fault.
When Page Fault occurs this problem arises, then the Least Recently Used
(LRU) Page Replacement Algorithm comes into picture.
The Least Recently Used (LRU) Page Replacement Algorithms works on a
certain principle. The principle is:
Replace the page with the page which is less dimension of time recently
used page in the past.
ANALYS CONTAC Page replacement
MENU
IS T algorithms
Example :
Consider the reference string 7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1
for a memory with three frames and calculate number of page faults by using
Least Recently Used (LRU) Page replacement algorithms
Points to Remember
Page Not Found - - - > Page Fault
Page Found - - - > Page Hit
Reference String:
ANALYS CONTAC Page replacement
MENU
IS T algorithms
Example :
Number of Page Hits = 12 The Ratio of Page Hit to the Page Fault = 12 : 8 - - - > 3 : 2---->1.5
Number of Page Faults = 8 The Page Hit Percentage = 12 * 100 / 20 = 60%
The Page Fault Percentage = 100 - Page Hit Percentage = 100 - 60 = 40%
ANALYS CONTAC Page replacement
MENU
IS T algorithms
thanks!