SlideShare a Scribd company logo
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

PPT
Pagereplacement algorithm(computional concept)
Siddhi Viradiya
 
PPTX
Page replacement algorithm
Lavina Gehlot
 
PPTX
Computer architecture page replacement algorithms
Mazin Alwaaly
 
PPTX
Virtual memory and page replacement algorithm
Muhammad Mansoor Ul Haq
 
PPTX
FIFO, LRU, OPTIMAL Page Replacement Algorithm
ArijitRoy118
 
PPTX
Page replacement algorithms
Piyush Rochwani
 
PPT
Page Replacement
chandinisanz
 
PPTX
141060753008 3715302
ITM Universe - Vadodara
 
Pagereplacement algorithm(computional concept)
Siddhi Viradiya
 
Page replacement algorithm
Lavina Gehlot
 
Computer architecture page replacement algorithms
Mazin Alwaaly
 
Virtual memory and page replacement algorithm
Muhammad Mansoor Ul Haq
 
FIFO, LRU, OPTIMAL Page Replacement Algorithm
ArijitRoy118
 
Page replacement algorithms
Piyush Rochwani
 
Page Replacement
chandinisanz
 
141060753008 3715302
ITM Universe - Vadodara
 

What's hot (20)

PPT
42 lru optimal
myrajendra
 
PPT
41 page replacement fifo
myrajendra
 
PPTX
Page replacement
Davin Abraham
 
PPTX
Page replacement algorithms
sangrampatil81
 
PPTX
Page Replacement Algorithms
Kashif Dayo
 
DOCX
Chosse a best algorithm for page replacement to reduce page fault and analysi...
MdAlAmin187
 
PDF
Virtual Memory
Mustafa Ugur Oduncu
 
PPT
Virtual memory
rapunzel08
 
PPT
Virtual memory
Mohammad Sadiq
 
PPTX
Operating system 38 page replacement
Vaibhav Khanna
 
PPTX
Virtual Memory in Windows
HanzlaRafique
 
PPT
Unit 2chapter 2 memory mgmt complete
Kalai Selvi
 
PPT
Operating System
Subhasis Dash
 
PPTX
virtual memory Operating system
Shaheen kousar
 
TXT
No sql
Bhanu Sekhar
 
PPT
Bijendra
bijendra
 
PDF
Migrating from MySQL to MongoDB
James Carr
 
PPTX
SQL Server2012 Enhancements
Abhishek Sur
 
42 lru optimal
myrajendra
 
41 page replacement fifo
myrajendra
 
Page replacement
Davin Abraham
 
Page replacement algorithms
sangrampatil81
 
Page Replacement Algorithms
Kashif Dayo
 
Chosse a best algorithm for page replacement to reduce page fault and analysi...
MdAlAmin187
 
Virtual Memory
Mustafa Ugur Oduncu
 
Virtual memory
rapunzel08
 
Virtual memory
Mohammad Sadiq
 
Operating system 38 page replacement
Vaibhav Khanna
 
Virtual Memory in Windows
HanzlaRafique
 
Unit 2chapter 2 memory mgmt complete
Kalai Selvi
 
Operating System
Subhasis Dash
 
virtual memory Operating system
Shaheen kousar
 
No sql
Bhanu Sekhar
 
Bijendra
bijendra
 
Migrating from MySQL to MongoDB
James Carr
 
SQL Server2012 Enhancements
Abhishek Sur
 
Ad

Similar to Page replacement alg (20)

PPTX
3_page_replacement_algorithms computer system and architecture
bebew44927
 
PPTX
page replacement.pptx
homipeh
 
PPTX
Operating system 40 lru algorithm
Vaibhav Khanna
 
PPT
Page replacement
sashi799
 
PPTX
Page replacement algorithm
Nikhil Katte
 
PDF
Pge Replacement Algorithm.pdf
82NehaPal
 
PPTX
Comparision of page replacement algorithms.pptx
SureshD94
 
PPT
Explain about replacement algorithms from these slides
ssusera979f41
 
PPT
Replacement.ppt operating system in BCA cu
PankajKumar790026
 
PPT
VM Page Replacement
sathish sak
 
PDF
pagereplacementalgorithmsa010a011-140520095310-phpapp01.pdf
MuhammadAbuzar68
 
PPT
9415070 deepak kumar raja kumar hgdxgfgcg
deepakraja1120
 
PPTX
Virtual memory management in Operating System
Rashmi Bhat
 
PPTX
operating system notes about virtual memory 4.pptx
panditestmail
 
DOCX
Lab9 LRU and FIFO.docx
PremaJain2
 
PPTX
Demand paging
Trinity Dwarka
 
PPT
page replacement algorithm powerpoint presentation
SREERAG36
 
PPTX
Page replacement_Architecture ppt (213015018+213015017).pptx
MD SAZID ZAMIL
 
PPTX
Page Replacement Algorithms.pptx
infomerlin
 
PDF
page repl.pdf
ogpaeog
 
3_page_replacement_algorithms computer system and architecture
bebew44927
 
page replacement.pptx
homipeh
 
Operating system 40 lru algorithm
Vaibhav Khanna
 
Page replacement
sashi799
 
Page replacement algorithm
Nikhil Katte
 
Pge Replacement Algorithm.pdf
82NehaPal
 
Comparision of page replacement algorithms.pptx
SureshD94
 
Explain about replacement algorithms from these slides
ssusera979f41
 
Replacement.ppt operating system in BCA cu
PankajKumar790026
 
VM Page Replacement
sathish sak
 
pagereplacementalgorithmsa010a011-140520095310-phpapp01.pdf
MuhammadAbuzar68
 
9415070 deepak kumar raja kumar hgdxgfgcg
deepakraja1120
 
Virtual memory management in Operating System
Rashmi Bhat
 
operating system notes about virtual memory 4.pptx
panditestmail
 
Lab9 LRU and FIFO.docx
PremaJain2
 
Demand paging
Trinity Dwarka
 
page replacement algorithm powerpoint presentation
SREERAG36
 
Page replacement_Architecture ppt (213015018+213015017).pptx
MD SAZID ZAMIL
 
Page Replacement Algorithms.pptx
infomerlin
 
page repl.pdf
ogpaeog
 
Ad

Recently uploaded (20)

PPTX
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PDF
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PPTX
Virus sequence retrieval from NCBI database
yamunaK13
 
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Basics and rules of probability with real-life uses
ravatkaran694
 
Virus sequence retrieval from NCBI database
yamunaK13
 

Page replacement alg

  • 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