SlideShare a Scribd company logo
1 of 18
PAGE REPLACEMENT
ALGORITHMS
P. Raveena Lakshmi, M.Sc.,
M.Phil.,
Assistant Professor
Page Replacement Algorithms
 Want lowest page-fault rate.
 Evaluate algorithm by running it on a
particular string of memory
references (reference string) and
computing the number of page faults
and page replacements on that
string.
 In all our examples, we use a few
recurring reference strings.
Graph of Page Faults vs. the Number of
Frames
The FIFO Policy
 Treats page frames allocated to a
process as a circular buffer:
When the buffer is full, the oldest page is
replaced. Hence first-in, first-out:
A frequently used page is often the oldest, so
it will be repeatedly paged out by FIFO.
Simple to implement:
requires only a pointer that circles through the
page frames of the process.
FIFO Page Replacement
First-In-First-Out (FIFO) Algorithm
 Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
 3 frames (3 pages can be in memory
at a time per process):
 4 frames:
 FIFO Replacement manifests Belady’s Anomaly:
 more frames  more page faults
1
2
3
1
2
3
4
1
2
5
3
4
9 page faults
1
2
3
1
2
3
5
1
2
4
5 10 page faults
44 3
FIFO Illustrating Belady’s Anomaly
A. Frank - P. Weisberg
Optimal Page Replacement
 The Optimal policy selects for
replacement the page that will not be used
for longest period of time.
 Impossible to implement (need to
know the future) but serves as a
standard to compare with the other
algorithms we shall study.
Optimal Page Replacement
A. Frank - P. Weisberg
Optimal Algorithm
 Reference string : 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
 4 frames example
 How do you know future use? You don’t!
 Used for measuring how well your algorithm
performs.
1
2
3
4
6 page faults
4 5
The LRU Policy
 Replaces the page that has not been
referenced for the longest time:
By the principle of locality, this should be
the page least likely to be referenced in
the near future.
performs nearly as well as the optimal
policy.
LRU Page Replacement
Least Recently Used (LRU) Algorithm
 Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
8 page faults
5
2
4
3
1
2
3
4
1
2
5
4
1
2
5
3
1
2
4
3
Implementation of the LRU Policy
 Each page could be tagged (in the page table
entry) with the time at each memory
reference.
 The LRU page is the one with the smallest
time value (needs to be searched at each
page fault).
 This would require expensive hardware and a
great deal of overhead.
 Consequently very few computer systems
provide sufficient hardware support for true
LRU replacement policy.
LRU Implementations
 Counter implementation:
 Every page entry has a counter; every time a page is
referenced through this entry, copy the clock into the
counter.
 When a page needs to be changed, look at the
counters to determine which are to change.
 Stack implementation – keep a stack of page
numbers in a double link form:
 Page referenced:
 move it to the top
 requires 6 pointers to be changed
 No search for replacement.
Use of a stack to implement LRU
A. Frank - P. Weisberg
• Stack implementation – keep a stack of page numbers in
a double link form:
– Page referenced:
• move it to the top
• requires 6 pointers to be changed
– No search for replacement – always take the bottom
one.
The Clock (Second Chance) Policy
 The set of frames candidate for replacement is
considered as a circular buffer.
 When a page is replaced, a pointer is set to point
to the next frame in buffer.
 A reference bit for each frame is set to 1
whenever:
 a page is first loaded into the frame.
 the corresponding page is referenced.
 When it is time to replace a page, the first frame
encountered with the reference bit set to 0 is
replaced:
 During the search for replacement, each reference bit
Clock Page-Replacement Algorithm
A. Frank - P. Weisberg

More Related Content

What's hot

42 lru optimal
42 lru optimal42 lru optimal
42 lru optimalmyrajendra
 
41 page replacement fifo
41 page replacement fifo41 page replacement fifo
41 page replacement fifomyrajendra
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithmssangrampatil81
 
Page Replacement Algorithms
Page Replacement AlgorithmsPage Replacement Algorithms
Page Replacement AlgorithmsKashif Dayo
 
Chosse a best algorithm for page replacement to reduce page fault and analysi...
Chosse a best algorithm for page replacement to reduce page fault and analysi...Chosse a best algorithm for page replacement to reduce page fault and analysi...
Chosse a best algorithm for page replacement to reduce page fault and analysi...MdAlAmin187
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryrapunzel08
 
Operating system 38 page replacement
Operating system 38 page replacementOperating system 38 page replacement
Operating system 38 page replacementVaibhav Khanna
 
Virtual Memory in Windows
Virtual Memory in Windows Virtual Memory in Windows
Virtual Memory in Windows HanzlaRafique
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt completeKalai Selvi
 
virtual memory Operating system
virtual memory Operating system virtual memory Operating system
virtual memory Operating system Shaheen kousar
 
Migrating from MySQL to MongoDB
Migrating from MySQL to MongoDBMigrating from MySQL to MongoDB
Migrating from MySQL to MongoDBJames Carr
 
SQL Server2012 Enhancements
SQL Server2012 EnhancementsSQL Server2012 Enhancements
SQL Server2012 EnhancementsAbhishek Sur
 

What's hot (20)

42 lru optimal
42 lru optimal42 lru optimal
42 lru optimal
 
41 page replacement fifo
41 page replacement fifo41 page replacement fifo
41 page replacement fifo
 
Page replacement
Page replacementPage replacement
Page replacement
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Page Replacement Algorithms
Page Replacement AlgorithmsPage Replacement Algorithms
Page Replacement Algorithms
 
Chosse a best algorithm for page replacement to reduce page fault and analysi...
Chosse a best algorithm for page replacement to reduce page fault and analysi...Chosse a best algorithm for page replacement to reduce page fault and analysi...
Chosse a best algorithm for page replacement to reduce page fault and analysi...
 
Mem mgt
Mem mgtMem mgt
Mem mgt
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Virtual memory
Virtual memory Virtual memory
Virtual memory
 
Operating system 38 page replacement
Operating system 38 page replacementOperating system 38 page replacement
Operating system 38 page replacement
 
Virtual Memory in Windows
Virtual Memory in Windows Virtual Memory in Windows
Virtual Memory in Windows
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt complete
 
Operating System
Operating SystemOperating System
Operating System
 
Vm
VmVm
Vm
 
virtual memory Operating system
virtual memory Operating system virtual memory Operating system
virtual memory Operating system
 
No sql
No sqlNo sql
No sql
 
Bijendra
BijendraBijendra
Bijendra
 
Migrating from MySQL to MongoDB
Migrating from MySQL to MongoDBMigrating from MySQL to MongoDB
Migrating from MySQL to MongoDB
 
SQL Server2012 Enhancements
SQL Server2012 EnhancementsSQL Server2012 Enhancements
SQL Server2012 Enhancements
 

Similar to PAGE REPLACEMENT ALGORITHMS COMPARED

Similar to PAGE REPLACEMENT ALGORITHMS COMPARED (20)

Page replacement
Page replacementPage replacement
Page replacement
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Ch09
Ch09Ch09
Ch09
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
 
OSCh10
OSCh10OSCh10
OSCh10
 
Ch10 OS
Ch10 OSCh10 OS
Ch10 OS
 
OS_Ch10
OS_Ch10OS_Ch10
OS_Ch10
 
Comparision of page replacement algorithms.pptx
Comparision of page replacement algorithms.pptxComparision of page replacement algorithms.pptx
Comparision of page replacement algorithms.pptx
 
Operating system 40 lru algorithm
Operating system 40 lru algorithmOperating system 40 lru algorithm
Operating system 40 lru algorithm
 
Replacement.ppt operating system in BCA cu
Replacement.ppt operating system in BCA cuReplacement.ppt operating system in BCA cu
Replacement.ppt operating system in BCA cu
 
LRU_Replacement-Policy.pdf
LRU_Replacement-Policy.pdfLRU_Replacement-Policy.pdf
LRU_Replacement-Policy.pdf
 
Distributed Operating System_3
Distributed Operating System_3Distributed Operating System_3
Distributed Operating System_3
 
O ssvv82014
O ssvv82014O ssvv82014
O ssvv82014
 
Virtual Memory Management Part - II.pdf
Virtual Memory Management Part - II.pdfVirtual Memory Management Part - II.pdf
Virtual Memory Management Part - II.pdf
 
page replacement.pptx
page replacement.pptxpage replacement.pptx
page replacement.pptx
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
Hybrid Page Replacement Algorithm
Hybrid Page Replacement AlgorithmHybrid Page Replacement Algorithm
Hybrid Page Replacement Algorithm
 
ikh311-06
ikh311-06ikh311-06
ikh311-06
 
Virtual Memory.pdf
Virtual Memory.pdfVirtual Memory.pdf
Virtual Memory.pdf
 
Virtual Memory sjkdhikejv vsdkjnksnv vkjhfvk
Virtual Memory sjkdhikejv vsdkjnksnv vkjhfvkVirtual Memory sjkdhikejv vsdkjnksnv vkjhfvk
Virtual Memory sjkdhikejv vsdkjnksnv vkjhfvk
 

Recently uploaded

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 

Recently uploaded (20)

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 

PAGE REPLACEMENT ALGORITHMS COMPARED

  • 1. PAGE REPLACEMENT ALGORITHMS P. Raveena Lakshmi, M.Sc., M.Phil., Assistant Professor
  • 2. Page Replacement Algorithms  Want lowest page-fault rate.  Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults and page replacements on that string.  In all our examples, we use a few recurring reference strings.
  • 3. Graph of Page Faults vs. the Number of Frames
  • 4. The FIFO Policy  Treats page frames allocated to a process as a circular buffer: When the buffer is full, the oldest page is replaced. Hence first-in, first-out: A frequently used page is often the oldest, so it will be repeatedly paged out by FIFO. Simple to implement: requires only a pointer that circles through the page frames of the process.
  • 6. First-In-First-Out (FIFO) Algorithm  Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5  3 frames (3 pages can be in memory at a time per process):  4 frames:  FIFO Replacement manifests Belady’s Anomaly:  more frames  more page faults 1 2 3 1 2 3 4 1 2 5 3 4 9 page faults 1 2 3 1 2 3 5 1 2 4 5 10 page faults 44 3
  • 7. FIFO Illustrating Belady’s Anomaly A. Frank - P. Weisberg
  • 8. Optimal Page Replacement  The Optimal policy selects for replacement the page that will not be used for longest period of time.  Impossible to implement (need to know the future) but serves as a standard to compare with the other algorithms we shall study.
  • 9. Optimal Page Replacement A. Frank - P. Weisberg
  • 10. Optimal Algorithm  Reference string : 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5  4 frames example  How do you know future use? You don’t!  Used for measuring how well your algorithm performs. 1 2 3 4 6 page faults 4 5
  • 11. The LRU Policy  Replaces the page that has not been referenced for the longest time: By the principle of locality, this should be the page least likely to be referenced in the near future. performs nearly as well as the optimal policy.
  • 13. Least Recently Used (LRU) Algorithm  Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 8 page faults 5 2 4 3 1 2 3 4 1 2 5 4 1 2 5 3 1 2 4 3
  • 14. Implementation of the LRU Policy  Each page could be tagged (in the page table entry) with the time at each memory reference.  The LRU page is the one with the smallest time value (needs to be searched at each page fault).  This would require expensive hardware and a great deal of overhead.  Consequently very few computer systems provide sufficient hardware support for true LRU replacement policy.
  • 15. LRU Implementations  Counter implementation:  Every page entry has a counter; every time a page is referenced through this entry, copy the clock into the counter.  When a page needs to be changed, look at the counters to determine which are to change.  Stack implementation – keep a stack of page numbers in a double link form:  Page referenced:  move it to the top  requires 6 pointers to be changed  No search for replacement.
  • 16. Use of a stack to implement LRU A. Frank - P. Weisberg • Stack implementation – keep a stack of page numbers in a double link form: – Page referenced: • move it to the top • requires 6 pointers to be changed – No search for replacement – always take the bottom one.
  • 17. The Clock (Second Chance) Policy  The set of frames candidate for replacement is considered as a circular buffer.  When a page is replaced, a pointer is set to point to the next frame in buffer.  A reference bit for each frame is set to 1 whenever:  a page is first loaded into the frame.  the corresponding page is referenced.  When it is time to replace a page, the first frame encountered with the reference bit set to 0 is replaced:  During the search for replacement, each reference bit
  • 18. Clock Page-Replacement Algorithm A. Frank - P. Weisberg