SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie PAGE REPLACEMENT ALGORITHMS COMPARED

Ähnlich wie 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
 

Kürzlich hochgeladen

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 

Kürzlich hochgeladen (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 

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