SlideShare a Scribd company logo
1 of 32
pAge
RePlacEmeNt
ALgoRITHms
Current Mechanism..
❖ The operating system uses the method of paging for memory
management.
❖ Memory Frames.
❖ Processes are loaded as frames.
❖ Page Table.
PROBLEM STATEMENT
❖ The demand occurs when the
operating system needs a page for
processing, and it is not present in
the main memory.
❖ Such situation is called Page
Fault.
Types of Page Replacement Algorithms
❖ First in First Out (FIFO) algorithm
❖ Optimal Page Replacement algorithm
❖ Least Recently Used (LRU) page replacement
algorithm
First in First Out
algorithm
First in First Out
❖ This is the simplest page replacement method in which the operating
system maintains all the pages in a queue.
❖ On a page fault, these pages from the front are removed first, and the
pages in demand are added.
HOW it
Works
Ex: Page Sequence: 1, 2, 3, 4, 5, 1, 3, 1, 6, 3, 2, 3
Total Page Fault = 9
ref 6 0 1 2 0 3 0 4 0 2 3 0 3 2
f 6 0 1 2 2 3 3 4 0 0 0 0 0 0
f 6 0 1 1 2 2 3 4 4 4 4 4 4
f 6 0 0 1 1 2 3 3 3 3 3 3
f 6 6 0 0 1 2 2 2 2 2 2
hit ✗ ✗ ✗ ✗ ✓ ✗ ✓ ✗ ✗ ✓ ✓ ✓ ✓ ✓
Ex: Page Sequence: 6,0,1,2,0,3,0,4,0,2,3,0,3,2
Advantages and Disadvantages
❖ Simple and easy to implement.
❖ Low overhead.
❏ Poor performance.
❏ Doesn’t consider the frequency of use or
last used time, simply replaces the oldest
page.
❏ Suffers from Belady’s Anomaly.
LRU Page
Replacement
algorithm
Least Recently Used Algorithm
❖ In this algorithm , pages are replaced which are not used for the
longest period of time.
❖ This algorithm can be seen as optimal page-replacement algorithm
looking backward in time, rather than forward.
❖ Counters and Stack are two primary ways in which this algorithm can
be implemented.
Least Recently Used Algorithm
❏ Counters
❖ Add the "time stamps" field to the page table entries.
❖ Add counter register to CPU. Counter is incremented every time a page
is referenced.
❖ When a page is referenced, the counter is copied to the "time stamps”
field.
❖ The victim page has the smallest "time stamps" value.
Least Recently Used Algorithm
❏ Counters
Least Recently Used Algorithm
❏ Counters
Total Page fault : 10
Least Recently Used Algorithm
❏ Stack
❖ The LRU replacement algorithm can also be accomplished by keeping
a stack of page numbers.
❖ When a page is referenced, it is removed from the stack and placed at
the top.
❖ Therefore, the most recently used page is always at the top of the stack
and the least recently used page is always at the bottom.
Least Recently Used Algorithm
❏ Stack
Algorithm
1.Start traversing the page
i) If set holds less page than capacity.
A. Insert page into the set one by one until the size
of set reaches capacity or all page requests are
processed.
B. Simultaneously maintain the recent occurred index
of each page in a map called indexes.
C. Increment page fault.
Algorithm
ii) Else
If Current page is present in set, do nothing else.
Else
A. Find the page in the set that was least recently used. We find
it using index array. We basically need to replace the page
with minimum index.
B. Replace the found page with current page.
C. Increment page faults.
D. Update index of current page.
2) Return page faults.
LRU Advantage
❏ Almost as good as OPT.
❏ No Belady’s Anomaly.
❏ Widely used for caches as well
LRU Disadvantage
❏ More complicated and expensive to implement than FIFO
algorithms:
❏ Determining an ordering based upon “time of last use”
❏ May require substantial hardware assistance
Optimal page
Replacement
algorithm
Optimal page replacement
❖ In this algorithm , pages are replaced which are not used for the
longest duration of time in the future.
❖ This algorithms replaces the page which will not be referred for so
long in future.
❖ This algorithm will never suffer from Belady’s anomaly.
Algorithm
1. Push the first page in the stack as per the memory demand.
2. Push the second page as per the memory demand
3. Push the third page until the memory if full.
4. As the stack is full,the page which is least recently used is popped.
5. Repeat step 4, until the page demand continues and until the
processing is over.
6. Terminate the program.
OPT in
Action
Q: 4 Frames. Page reference string: 1,2,3,4,5,1,3,1,6,3,2,3.
Soln:
Total page faults: 6
Q: 3 Frames. Page reference string: 7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1
Soln:
Total page faults: 9
Implementation
❖ Since future cannot be predicted in general,the algorithm
cannot really be implemented
❖ Sometimes,if a program is used repeatedly, its behaviour may
be known
❖ OPT can be approximated
❖ OPT is set a benchmark.
Advantages
❖ It is less complex and easy to understand.
❖ A page is replaced with minimum fuss.
❖ Simple data structure are used for this purpose
Disadvantages
❖ Not all operating system can implement this
algorithm
❖ Error detection is harder
CONCLUSION
Conclusion
In the above methods or algorithms .we have found that optimal page replacement algorithm results
in the best algorithm because the average page faults in all three cases with page frame size 2,3 and
4 is less as compared to FIFO and LRU.
Considering above example: Page faults for respective algorithms were
➢ FIFO: 9 page faults.
➢ LRU: 8 page faults.
➢ OPTIMAL: 6 page faults.
Though optimal page replacement algorithm is best and efficient as compared to other two but it
cannot be implemented because we can't predict the future. So it is best for theory but LRU page
replacement algorithm is used in most of the cases.

More Related Content

What's hot

What's hot (20)

DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Semaphores
SemaphoresSemaphores
Semaphores
 
Applets in java
Applets in javaApplets in java
Applets in java
 
Memory management
Memory managementMemory management
Memory management
 
Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating system
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaion
 
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Data structure,abstraction,abstract data type,static and dynamic,time and spa...Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
 
Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock Galvin
 
Page Replacement
Page ReplacementPage Replacement
Page Replacement
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
 
Array in c++
Array in c++Array in c++
Array in c++
 
Array ppt
Array pptArray ppt
Array ppt
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
Process of operating system
Process of operating systemProcess of operating system
Process of operating system
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Thread model in java
Thread model in javaThread model in java
Thread model in java
 

Similar to page replacement.pptx

Similar to page replacement.pptx (20)

virtual memory Operating system
virtual memory Operating system virtual memory Operating system
virtual memory Operating system
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt complete
 
Page replacement
Page replacementPage replacement
Page replacement
 
Memory management
Memory managementMemory management
Memory management
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
Operating System
Operating SystemOperating System
Operating System
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Operating system 38 page replacement
Operating system 38 page replacementOperating system 38 page replacement
Operating system 38 page replacement
 
Mem mgt
Mem mgtMem mgt
Mem mgt
 
Virtual Memory.pdf
Virtual Memory.pdfVirtual Memory.pdf
Virtual Memory.pdf
 
Operating system 37 demand paging
Operating system 37 demand pagingOperating system 37 demand paging
Operating system 37 demand paging
 
VM Page Replacement
VM Page ReplacementVM Page Replacement
VM Page Replacement
 
LecturePPT_Unit_3b_AY2021-22_TechngVrsn.ppt
LecturePPT_Unit_3b_AY2021-22_TechngVrsn.pptLecturePPT_Unit_3b_AY2021-22_TechngVrsn.ppt
LecturePPT_Unit_3b_AY2021-22_TechngVrsn.ppt
 
Pge Replacement Algorithm.pdf
Pge Replacement Algorithm.pdfPge Replacement Algorithm.pdf
Pge Replacement Algorithm.pdf
 
OSCh10
OSCh10OSCh10
OSCh10
 
Ch10 OS
Ch10 OSCh10 OS
Ch10 OS
 
OS_Ch10
OS_Ch10OS_Ch10
OS_Ch10
 
4.-CSE-3201_OL1_Paging.pdf
4.-CSE-3201_OL1_Paging.pdf4.-CSE-3201_OL1_Paging.pdf
4.-CSE-3201_OL1_Paging.pdf
 
O ssvv82014
O ssvv82014O ssvv82014
O ssvv82014
 

Recently uploaded

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

page replacement.pptx

  • 2. Current Mechanism.. ❖ The operating system uses the method of paging for memory management. ❖ Memory Frames. ❖ Processes are loaded as frames. ❖ Page Table.
  • 3.
  • 4. PROBLEM STATEMENT ❖ The demand occurs when the operating system needs a page for processing, and it is not present in the main memory. ❖ Such situation is called Page Fault.
  • 5. Types of Page Replacement Algorithms ❖ First in First Out (FIFO) algorithm ❖ Optimal Page Replacement algorithm ❖ Least Recently Used (LRU) page replacement algorithm
  • 6. First in First Out algorithm
  • 7. First in First Out ❖ This is the simplest page replacement method in which the operating system maintains all the pages in a queue. ❖ On a page fault, these pages from the front are removed first, and the pages in demand are added.
  • 9. Ex: Page Sequence: 1, 2, 3, 4, 5, 1, 3, 1, 6, 3, 2, 3 Total Page Fault = 9
  • 10. ref 6 0 1 2 0 3 0 4 0 2 3 0 3 2 f 6 0 1 2 2 3 3 4 0 0 0 0 0 0 f 6 0 1 1 2 2 3 4 4 4 4 4 4 f 6 0 0 1 1 2 3 3 3 3 3 3 f 6 6 0 0 1 2 2 2 2 2 2 hit ✗ ✗ ✗ ✗ ✓ ✗ ✓ ✗ ✗ ✓ ✓ ✓ ✓ ✓ Ex: Page Sequence: 6,0,1,2,0,3,0,4,0,2,3,0,3,2
  • 11. Advantages and Disadvantages ❖ Simple and easy to implement. ❖ Low overhead. ❏ Poor performance. ❏ Doesn’t consider the frequency of use or last used time, simply replaces the oldest page. ❏ Suffers from Belady’s Anomaly.
  • 13. Least Recently Used Algorithm ❖ In this algorithm , pages are replaced which are not used for the longest period of time. ❖ This algorithm can be seen as optimal page-replacement algorithm looking backward in time, rather than forward. ❖ Counters and Stack are two primary ways in which this algorithm can be implemented.
  • 14. Least Recently Used Algorithm ❏ Counters ❖ Add the "time stamps" field to the page table entries. ❖ Add counter register to CPU. Counter is incremented every time a page is referenced. ❖ When a page is referenced, the counter is copied to the "time stamps” field. ❖ The victim page has the smallest "time stamps" value.
  • 15. Least Recently Used Algorithm ❏ Counters
  • 16. Least Recently Used Algorithm ❏ Counters Total Page fault : 10
  • 17. Least Recently Used Algorithm ❏ Stack ❖ The LRU replacement algorithm can also be accomplished by keeping a stack of page numbers. ❖ When a page is referenced, it is removed from the stack and placed at the top. ❖ Therefore, the most recently used page is always at the top of the stack and the least recently used page is always at the bottom.
  • 18. Least Recently Used Algorithm ❏ Stack
  • 19. Algorithm 1.Start traversing the page i) If set holds less page than capacity. A. Insert page into the set one by one until the size of set reaches capacity or all page requests are processed. B. Simultaneously maintain the recent occurred index of each page in a map called indexes. C. Increment page fault.
  • 20. Algorithm ii) Else If Current page is present in set, do nothing else. Else A. Find the page in the set that was least recently used. We find it using index array. We basically need to replace the page with minimum index. B. Replace the found page with current page. C. Increment page faults. D. Update index of current page. 2) Return page faults.
  • 21. LRU Advantage ❏ Almost as good as OPT. ❏ No Belady’s Anomaly. ❏ Widely used for caches as well LRU Disadvantage ❏ More complicated and expensive to implement than FIFO algorithms: ❏ Determining an ordering based upon “time of last use” ❏ May require substantial hardware assistance
  • 23. Optimal page replacement ❖ In this algorithm , pages are replaced which are not used for the longest duration of time in the future. ❖ This algorithms replaces the page which will not be referred for so long in future. ❖ This algorithm will never suffer from Belady’s anomaly.
  • 24. Algorithm 1. Push the first page in the stack as per the memory demand. 2. Push the second page as per the memory demand 3. Push the third page until the memory if full. 4. As the stack is full,the page which is least recently used is popped. 5. Repeat step 4, until the page demand continues and until the processing is over. 6. Terminate the program.
  • 26. Q: 4 Frames. Page reference string: 1,2,3,4,5,1,3,1,6,3,2,3. Soln: Total page faults: 6
  • 27. Q: 3 Frames. Page reference string: 7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1 Soln: Total page faults: 9
  • 28. Implementation ❖ Since future cannot be predicted in general,the algorithm cannot really be implemented ❖ Sometimes,if a program is used repeatedly, its behaviour may be known ❖ OPT can be approximated ❖ OPT is set a benchmark.
  • 29. Advantages ❖ It is less complex and easy to understand. ❖ A page is replaced with minimum fuss. ❖ Simple data structure are used for this purpose
  • 30. Disadvantages ❖ Not all operating system can implement this algorithm ❖ Error detection is harder
  • 32. Conclusion In the above methods or algorithms .we have found that optimal page replacement algorithm results in the best algorithm because the average page faults in all three cases with page frame size 2,3 and 4 is less as compared to FIFO and LRU. Considering above example: Page faults for respective algorithms were ➢ FIFO: 9 page faults. ➢ LRU: 8 page faults. ➢ OPTIMAL: 6 page faults. Though optimal page replacement algorithm is best and efficient as compared to other two but it cannot be implemented because we can't predict the future. So it is best for theory but LRU page replacement algorithm is used in most of the cases.

Editor's Notes

  1. 7 0 1 2 0 3 0 4 2 3 0 3 2 3