SlideShare a Scribd company logo
A thesis in the Department of Computer Science and Engineering presented
in partial fulfillment of the requirements for the course syllabus of
Operating System
22th
August, 2019
Author:
Md. Al-Amin ID: 172015031
Nur Karim ID: 172015030
Ashraful Alam ID: 172015042
Supervisor:
Jesiya Sarmin
Chosse a best algorithm for page replacement to
reduce page fault and analysis their with C#
Green University of Bangladesh
Computer Science and Engineering
ABSTRACT:
This thesis is mainly focused on finding out the best page replacement algorithm to reduce page fault.
Page replacement algorithms choose pages to swap out from the memory when a new page needs for
allocation on the memory. Each algorithm has the objective to minimize the number of page faults.
With minimum page faults, the performance of the process is increased. In this paper, study and
analysis of three algorithms. They are-
 First in First out (FIFO)
 Least Recently Used (LRU)
 Optimal Page Replacement (OPT)
Keywords: FIFO, LRU, OPT, page fault, page replacement algorithm.
INTRODUCTION:
A page fault occurs when a program attempts to access a block of memory that is not stored in the
physical memory, or RAM. The fault notifies the operating system that it must locate the data in virtual
memory, then transfer it from the storage device, such as an HDD or SSD, to the system RAM.
Fig-01: How to occur a page fault
There are different policies regarding how to select a page to be swapped out when a page fault occurs
to create space for a new page. These policies are called page replacement algorithms. Several page
replacement algorithms exist like Optimal Page Replacement, First in First out, Least Recently Used,
Least Frequently Used, Most Frequently Used, Not Frequently Used, Second Chance Page
Replacement, Clock Page Replacement etc. In this paper, we implement three algorithms i.e. Optimal
Page Replacement, First in First out and Least Frequently Used using Visual Studio C#.
Working procedure on page replacement algorithm:
The Operating System has to choose a page to remove from memory for creating space for a new page
that has to be brought in. Page Replacement Algorithms are used for the selection of the page to replace.
In this paper, three page replacement algorithms are discussed.
First In First Out (FIFO) page replacement algorithm:
The First in First out (FIFO) page replacement algorithm is the simplest approach of replacing the page.
The idea is to replace the oldest page in main memory from all the pages i.e. that page is replaced which
has been in main memory for the greatest period of time. A FIFO queue can be created to hold all the
pages in main memory. The page that is at the front is replaced and when the page is fetched into
memory it is inserted at the Rear end. For this reason, FIFO algorithm is seldom used. Let us consider
a 20 pages common reference string- 1,7,14,0,9,4,18,18,2,4,5,5,1,7,1,11,15,2,7,16 for two, three, four
and five page frames in memory to find the page faults using FIFO page replacement algorithm. 5 page
frames output below-
Fig-02: Page fault output by use FIFO
In the above fig-01 with 5 page frames, the number of page faults is 15. The advantage of FIFO page
replacement algorithm is easy to implement and disadvantage is that it suffers from Belady’s anomaly.
Belady’s anomaly is an unexpected result in FIFO page replacement algorithm. In some of the reference
strings, increasing the size of the memory increases the page fault rate.
Least Recently Used (LRU) page replacement algorithm:
Least Recently Used (LRU) Page Replacement Algorithm replaces the page in memory that has not
been used for the longest period of time. The problem with this algorithm is the complexity in
implementation. The implementation may involve hardware or software support. The implementation
of this policy can be possible using matrix, counters, linked list etc. Consider the same reference string
1,7,14,0,9,4,18,18,2,4,5,5,1,7,1,11,15,2,7,16 with main memory that can accommodate 2, 3 4, and 5
page frames respectively to find the page faults using LRU page replacement algorithm.
Fig-03: Page fault output by use LRU
In the above fig-02 with 5 page frames, the number of page faults is also same15 as FIFO. The
advantage of LRU page replacement algorithm is that it does not suffer from Belady’s anomaly and
the disadvantage is that it needs expensive hardware support or additional data structure to implement.
Optimal (OPT) page replacement algorithm:
In Optimal page replacement algorithm, the page that will not be used for the longest period of time is
replaced to make space for the requested page. This algorithm is easy to explain theoretically but
difficult to implement because it requires to have accurate information of future events. Therefore its
use is limited to serving as a benchmark to which other page replacement algorithms may be compared.
This algorithm never suffers from belady’s anomaly. Consider again the same reference string
1,7,14,0,9,4,18,18,2,4,5,5,1,7,1,11,15,2,7,16 with main memory that can accommodate 2, 3, 4, and 5
page frames to find the page faults using OPT page replacement algorithm.
Fig-04: Page fault output by use OPT
In the above reference string with 4 page frames, the number of page faults is 05. The advantage of
optimal page replacement algorithm is that it has least rate of occurrences of page fault and the
disadvantage is that it is difficult to implement because it requires accurate knowledge of future events.
Experimental Result:
The purpose is to test the performance of the 3 algorithms with the same sequence. We have chosen a
reference string of 20 pages having the sequence: 1,7,14,0,9,4,18,18,2,4,5,5,1,7,1,11,15,2,7,16; firstly
we have tested it for two, three and four page frames. Above all the screenshot for 5 page frames is
shown in figure. In the application firstly it requires the number of empty frames, then it requires the
length of the reference string and at last the reference string itself. The number of page faults can be
calculated for all the three algorithms. A table with number of page faults, for each algorithm, with
page frame size 2, 3, 4 and 5 is generated as shown in table 1. With 2 page frames, FIFO generates 17
page faults, LRU generates also 17 page faults and Optimal generates 15 page faults. Similarly with 3
page frames, FIFO generates 16 page faults, LRU generates also 16 page faults and Optimal generates
13 page faults. With 4 page frames, FIFO generates 15 page faults, LRU generates 16 page faults and
Optimal generates 12 page faults. With 5 page frames, FIFO generates 15 page faults, LRU generates
15 page faults and Optimal generates 12 page faults.
Algorithm FIFO LRU OPT
Page Frames(2) 17 17 15
Page Frames(3) 16 16 13
Page Frames(4) 15 16 12
Page Frames(5) 15 15 12
Average 15.75 16 13
Table 1: Page faults for frame size 2, 3 4, and 5.
The graphical representation is shown in fig-5 in the below. From the figure, it is very much clear
that the optimal algorithm is the best among all the three page replacement algorithms. There
Fig-5: Graph showing page faults with 2, 3, 4 and 5 page frames and their average.
0
2
4
6
8
10
12
14
16
18
2 Frames 3 Frames 4 Frames 5 Frames Average
PageFault Ration
FIFO
LRU
OPT
Conclusion:
In the above study, we have found that optimal page replacement algorithm results the best
algorithm because the average page faults in all the three cases with page frame size 2, 3, 4 and 5
is less as compared to FIFO and LRU. A good page replacement algorithm reduces the number of
page faults. In FIFO algorithm, some reference strings produces unexpected results called Belady’s
anomaly i.e. by increasing the number of page frames, the page fault also increases. In that case
LRU works better than FIFO. In this paper, three different page replacement algorithms are studied
and implemented with C# and compare with respect to page faults.

More Related Content

What's hot

Library management system
Library management systemLibrary management system
Library management system
ashu6
 
Chapter3-evaluation techniques HCI
Chapter3-evaluation techniques HCIChapter3-evaluation techniques HCI
Chapter3-evaluation techniques HCI
Shafy Fify
 
System of systems classification
System of systems classificationSystem of systems classification
System of systems classification
sommerville-videos
 

What's hot (20)

Library management system
Library management systemLibrary management system
Library management system
 
Social, professional, ethical and legal issues
Social, professional, ethical and legal issuesSocial, professional, ethical and legal issues
Social, professional, ethical and legal issues
 
HCI 3e - Ch 12: Cognitive models
HCI 3e - Ch 12:  Cognitive modelsHCI 3e - Ch 12:  Cognitive models
HCI 3e - Ch 12: Cognitive models
 
Grasp patterns and its types
Grasp patterns and its typesGrasp patterns and its types
Grasp patterns and its types
 
Chapter3-evaluation techniques HCI
Chapter3-evaluation techniques HCIChapter3-evaluation techniques HCI
Chapter3-evaluation techniques HCI
 
Usability Engineering Presentation Slides
Usability Engineering Presentation SlidesUsability Engineering Presentation Slides
Usability Engineering Presentation Slides
 
Virtualization in cloud computing
Virtualization in cloud computingVirtualization in cloud computing
Virtualization in cloud computing
 
Atm project
Atm projectAtm project
Atm project
 
Online shopping Report
Online shopping ReportOnline shopping Report
Online shopping Report
 
Cluster computing
Cluster computingCluster computing
Cluster computing
 
cloud computing:Types of virtualization
cloud computing:Types of virtualizationcloud computing:Types of virtualization
cloud computing:Types of virtualization
 
Airline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringAirline Reservation System - Software Engineering
Airline Reservation System - Software Engineering
 
System of systems classification
System of systems classificationSystem of systems classification
System of systems classification
 
WEB INTERFACE DESIGN
WEB INTERFACE DESIGNWEB INTERFACE DESIGN
WEB INTERFACE DESIGN
 
Parallelism
ParallelismParallelism
Parallelism
 
Human Computer Interaction Chapter 5 Universal Design and User Support - Dr....
Human Computer Interaction Chapter 5 Universal Design and User Support -  Dr....Human Computer Interaction Chapter 5 Universal Design and User Support -  Dr....
Human Computer Interaction Chapter 5 Universal Design and User Support - Dr....
 
Wimp interface
Wimp interfaceWimp interface
Wimp interface
 
Unified Modeling Language
Unified Modeling LanguageUnified Modeling Language
Unified Modeling Language
 
HCI 3e - Ch 13: Socio-organizational issues and stakeholder requirements
HCI 3e - Ch 13:  Socio-organizational issues and stakeholder requirementsHCI 3e - Ch 13:  Socio-organizational issues and stakeholder requirements
HCI 3e - Ch 13: Socio-organizational issues and stakeholder requirements
 
Distributed Operating System
Distributed Operating SystemDistributed Operating System
Distributed Operating System
 

Similar to Chosse a best algorithm for page replacement to reduce page fault and analysis their with c#

Ch10 OS
Ch10 OSCh10 OS
Ch10 OS
C.U
 
42 lru optimal
42 lru optimal42 lru optimal
42 lru optimal
myrajendra
 
Understanding operating systems 5th ed ch03
Understanding operating systems 5th ed ch03Understanding operating systems 5th ed ch03
Understanding operating systems 5th ed ch03
BarrBoy
 

Similar to Chosse a best algorithm for page replacement to reduce page fault and analysis their with c# (20)

Operating system 39 first in first out algorithm
Operating system 39 first in first out algorithmOperating system 39 first in first out algorithm
Operating system 39 first in first out algorithm
 
Virtual Memory in Operating System
Virtual Memory in Operating SystemVirtual Memory in Operating System
Virtual Memory in Operating System
 
STORAGE MANAGEMENT AND PAGING ALGORITHMS.pptx
STORAGE MANAGEMENT AND PAGING ALGORITHMS.pptxSTORAGE MANAGEMENT AND PAGING ALGORITHMS.pptx
STORAGE MANAGEMENT AND PAGING ALGORITHMS.pptx
 
Page replacement
Page replacementPage replacement
Page replacement
 
An input enhancement technique to maximize the performance of page replacemen...
An input enhancement technique to maximize the performance of page replacemen...An input enhancement technique to maximize the performance of page replacemen...
An input enhancement technique to maximize the performance of page replacemen...
 
Hybrid Page Replacement Algorithm
Hybrid Page Replacement AlgorithmHybrid Page Replacement Algorithm
Hybrid Page Replacement Algorithm
 
Mem mgt
Mem mgtMem mgt
Mem mgt
 
OS_Ch10
OS_Ch10OS_Ch10
OS_Ch10
 
Ch10 OS
Ch10 OSCh10 OS
Ch10 OS
 
OSCh10
OSCh10OSCh10
OSCh10
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
42 lru optimal
42 lru optimal42 lru optimal
42 lru optimal
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt complete
 
Understanding operating systems 5th ed ch03
Understanding operating systems 5th ed ch03Understanding operating systems 5th ed ch03
Understanding operating systems 5th ed ch03
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
 
Operating System
Operating SystemOperating System
Operating System
 
Ch09
Ch09Ch09
Ch09
 
Pge Replacement Algorithm.pdf
Pge Replacement Algorithm.pdfPge Replacement Algorithm.pdf
Pge Replacement Algorithm.pdf
 
page replacement.pptx
page replacement.pptxpage replacement.pptx
page replacement.pptx
 
Page replacement alg
Page replacement algPage replacement alg
Page replacement alg
 

More from MdAlAmin187

More from MdAlAmin187 (20)

Decision tree in artificial intelligence
Decision tree in artificial intelligenceDecision tree in artificial intelligence
Decision tree in artificial intelligence
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 
Assignment on field study of Mahera & Pakutia Jomidar Bari
Assignment on field study of Mahera & Pakutia Jomidar BariAssignment on field study of Mahera & Pakutia Jomidar Bari
Assignment on field study of Mahera & Pakutia Jomidar Bari
 
Social problems in Bangladesh
Social problems in BangladeshSocial problems in Bangladesh
Social problems in Bangladesh
 
History of Language & History of Bangla Language
History of Language & History of Bangla LanguageHistory of Language & History of Bangla Language
History of Language & History of Bangla Language
 
Lu Decomposition
Lu DecompositionLu Decomposition
Lu Decomposition
 
Non Linear Equation
Non Linear EquationNon Linear Equation
Non Linear Equation
 
Smart home technology LaTeX paper
Smart home technology LaTeX paperSmart home technology LaTeX paper
Smart home technology LaTeX paper
 
Emo 8086 code for Loop
Emo 8086 code for LoopEmo 8086 code for Loop
Emo 8086 code for Loop
 
Emo 8086 code for add
Emo 8086 code for addEmo 8086 code for add
Emo 8086 code for add
 
Emo 8086 code for Subtraction
Emo 8086 code for SubtractionEmo 8086 code for Subtraction
Emo 8086 code for Subtraction
 
Virtual local area network(VLAN)
Virtual local area network(VLAN)Virtual local area network(VLAN)
Virtual local area network(VLAN)
 
Telnet configuration
Telnet configurationTelnet configuration
Telnet configuration
 
Standard & Extended ACL Configuration
Standard & Extended ACL ConfigurationStandard & Extended ACL Configuration
Standard & Extended ACL Configuration
 
Topological Sort
Topological SortTopological Sort
Topological Sort
 
Verification of Solenoidal & Irrotational
Verification of Solenoidal & IrrotationalVerification of Solenoidal & Irrotational
Verification of Solenoidal & Irrotational
 
Bangla spell checker & suggestion generator
Bangla spell checker & suggestion generatorBangla spell checker & suggestion generator
Bangla spell checker & suggestion generator
 
Different types of DBMS
Different types of DBMSDifferent types of DBMS
Different types of DBMS
 
Discrete mathematics
Discrete mathematicsDiscrete mathematics
Discrete mathematics
 
Math presentation
Math presentationMath presentation
Math presentation
 

Recently uploaded

Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 

Recently uploaded (20)

Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Keeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesKeeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security Services
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 

Chosse a best algorithm for page replacement to reduce page fault and analysis their with c#

  • 1. A thesis in the Department of Computer Science and Engineering presented in partial fulfillment of the requirements for the course syllabus of Operating System 22th August, 2019 Author: Md. Al-Amin ID: 172015031 Nur Karim ID: 172015030 Ashraful Alam ID: 172015042 Supervisor: Jesiya Sarmin Chosse a best algorithm for page replacement to reduce page fault and analysis their with C# Green University of Bangladesh Computer Science and Engineering
  • 2. ABSTRACT: This thesis is mainly focused on finding out the best page replacement algorithm to reduce page fault. Page replacement algorithms choose pages to swap out from the memory when a new page needs for allocation on the memory. Each algorithm has the objective to minimize the number of page faults. With minimum page faults, the performance of the process is increased. In this paper, study and analysis of three algorithms. They are-  First in First out (FIFO)  Least Recently Used (LRU)  Optimal Page Replacement (OPT) Keywords: FIFO, LRU, OPT, page fault, page replacement algorithm. INTRODUCTION: A page fault occurs when a program attempts to access a block of memory that is not stored in the physical memory, or RAM. The fault notifies the operating system that it must locate the data in virtual memory, then transfer it from the storage device, such as an HDD or SSD, to the system RAM. Fig-01: How to occur a page fault There are different policies regarding how to select a page to be swapped out when a page fault occurs to create space for a new page. These policies are called page replacement algorithms. Several page replacement algorithms exist like Optimal Page Replacement, First in First out, Least Recently Used,
  • 3. Least Frequently Used, Most Frequently Used, Not Frequently Used, Second Chance Page Replacement, Clock Page Replacement etc. In this paper, we implement three algorithms i.e. Optimal Page Replacement, First in First out and Least Frequently Used using Visual Studio C#. Working procedure on page replacement algorithm: The Operating System has to choose a page to remove from memory for creating space for a new page that has to be brought in. Page Replacement Algorithms are used for the selection of the page to replace. In this paper, three page replacement algorithms are discussed. First In First Out (FIFO) page replacement algorithm: The First in First out (FIFO) page replacement algorithm is the simplest approach of replacing the page. The idea is to replace the oldest page in main memory from all the pages i.e. that page is replaced which has been in main memory for the greatest period of time. A FIFO queue can be created to hold all the pages in main memory. The page that is at the front is replaced and when the page is fetched into memory it is inserted at the Rear end. For this reason, FIFO algorithm is seldom used. Let us consider a 20 pages common reference string- 1,7,14,0,9,4,18,18,2,4,5,5,1,7,1,11,15,2,7,16 for two, three, four and five page frames in memory to find the page faults using FIFO page replacement algorithm. 5 page frames output below- Fig-02: Page fault output by use FIFO
  • 4. In the above fig-01 with 5 page frames, the number of page faults is 15. The advantage of FIFO page replacement algorithm is easy to implement and disadvantage is that it suffers from Belady’s anomaly. Belady’s anomaly is an unexpected result in FIFO page replacement algorithm. In some of the reference strings, increasing the size of the memory increases the page fault rate. Least Recently Used (LRU) page replacement algorithm: Least Recently Used (LRU) Page Replacement Algorithm replaces the page in memory that has not been used for the longest period of time. The problem with this algorithm is the complexity in implementation. The implementation may involve hardware or software support. The implementation of this policy can be possible using matrix, counters, linked list etc. Consider the same reference string 1,7,14,0,9,4,18,18,2,4,5,5,1,7,1,11,15,2,7,16 with main memory that can accommodate 2, 3 4, and 5 page frames respectively to find the page faults using LRU page replacement algorithm. Fig-03: Page fault output by use LRU In the above fig-02 with 5 page frames, the number of page faults is also same15 as FIFO. The advantage of LRU page replacement algorithm is that it does not suffer from Belady’s anomaly and the disadvantage is that it needs expensive hardware support or additional data structure to implement.
  • 5. Optimal (OPT) page replacement algorithm: In Optimal page replacement algorithm, the page that will not be used for the longest period of time is replaced to make space for the requested page. This algorithm is easy to explain theoretically but difficult to implement because it requires to have accurate information of future events. Therefore its use is limited to serving as a benchmark to which other page replacement algorithms may be compared. This algorithm never suffers from belady’s anomaly. Consider again the same reference string 1,7,14,0,9,4,18,18,2,4,5,5,1,7,1,11,15,2,7,16 with main memory that can accommodate 2, 3, 4, and 5 page frames to find the page faults using OPT page replacement algorithm. Fig-04: Page fault output by use OPT In the above reference string with 4 page frames, the number of page faults is 05. The advantage of optimal page replacement algorithm is that it has least rate of occurrences of page fault and the disadvantage is that it is difficult to implement because it requires accurate knowledge of future events.
  • 6. Experimental Result: The purpose is to test the performance of the 3 algorithms with the same sequence. We have chosen a reference string of 20 pages having the sequence: 1,7,14,0,9,4,18,18,2,4,5,5,1,7,1,11,15,2,7,16; firstly we have tested it for two, three and four page frames. Above all the screenshot for 5 page frames is shown in figure. In the application firstly it requires the number of empty frames, then it requires the length of the reference string and at last the reference string itself. The number of page faults can be calculated for all the three algorithms. A table with number of page faults, for each algorithm, with page frame size 2, 3, 4 and 5 is generated as shown in table 1. With 2 page frames, FIFO generates 17 page faults, LRU generates also 17 page faults and Optimal generates 15 page faults. Similarly with 3 page frames, FIFO generates 16 page faults, LRU generates also 16 page faults and Optimal generates 13 page faults. With 4 page frames, FIFO generates 15 page faults, LRU generates 16 page faults and Optimal generates 12 page faults. With 5 page frames, FIFO generates 15 page faults, LRU generates 15 page faults and Optimal generates 12 page faults. Algorithm FIFO LRU OPT Page Frames(2) 17 17 15 Page Frames(3) 16 16 13 Page Frames(4) 15 16 12 Page Frames(5) 15 15 12 Average 15.75 16 13 Table 1: Page faults for frame size 2, 3 4, and 5. The graphical representation is shown in fig-5 in the below. From the figure, it is very much clear that the optimal algorithm is the best among all the three page replacement algorithms. There Fig-5: Graph showing page faults with 2, 3, 4 and 5 page frames and their average. 0 2 4 6 8 10 12 14 16 18 2 Frames 3 Frames 4 Frames 5 Frames Average PageFault Ration FIFO LRU OPT
  • 7. Conclusion: In the above study, we have found that optimal page replacement algorithm results the best algorithm because the average page faults in all the three cases with page frame size 2, 3, 4 and 5 is less as compared to FIFO and LRU. A good page replacement algorithm reduces the number of page faults. In FIFO algorithm, some reference strings produces unexpected results called Belady’s anomaly i.e. by increasing the number of page frames, the page fault also increases. In that case LRU works better than FIFO. In this paper, three different page replacement algorithms are studied and implemented with C# and compare with respect to page faults.