SlideShare une entreprise Scribd logo
1  sur  34
Télécharger pour lire hors ligne
Page Replacement Algorithms
FIFO, NRU, LRU, NFU...
Index
1. Paging
2. Page Replacement
3. Algorithms
4. Conclusion
5. References
Topic
S. No.
a. Optimal
b. FIFO
c. NFU
d. NRU
e. LRU
f. Second Chance
g. CLOCK
h. Random
i. Working Set
i
Plan of Action
• What is paging?
• What is page replacement?
• What are the types of page replacement?
• Why we need a page replacement algorithm?
• What are the algorithms?
What is Paging?
• The OS divides virtual memory and the main
memory into units, called pages.
• Each used page can be either in secondary
memory or in a page frame in main memory.
• A frame does not have to comprise a single
physically contiguous region in secondary
storage.
What is page replacement?
• When memory located in secondary memory is
needed, it can be retrieved back to main memory.
• Process of storing data from main memory to
secondary memory ->swapping out
• Retrieving data back to main memory ->swapping
in
Fig: Page Replacement
What are Page Replacement
Algorithms?
• Deals with which pages need to be swapped out
and which are the ones that need to be swapped
in
• The efficiency lies in the least time that is wasted
for a page to be paged in
Types
• Local Page Replacement Strategy
• Global Page Replacement Strategy
Why we need a page replacement
algorithm?
• The main goal of page replacement algorithms is
to provide lowest page fault rate.
START
Send Page
request
Page found?
yes
no
HIT
FAULT
STOP
Fetch page
No. of Page Faults Vs No. of Frames
Algorithms
• First In First Out
• Optimal Replacement
• Not Recently Used
• Second Chance
• CLOCK
• Not Frequently Used
• Least Recently Used
• Random Replacement
• Working Set Replacement
First-In First-Out (FIFO)
• Pages in main memory are kept in a list
• Newest page is in head and the oldest in tail
• It does not take advantage of page access
patterns or frequency
Fig: FIFO
FIFO Example
Oldest
Hit Hit Hit
Newest
Fig: FIFO example
Optimal Replacement (OPT)
• When the memory is full, evict a page that will
be unreferenced for the longest time
• The OS keeps track of all pages referenced by the
program
• Only if the program's memory reference pattern
is relatively consistent
OPTIMAL Example
Referenced last
Hit Hit Hit
Hit Hit Hit
Fig: OPTIMAL example
Not Recently Used (NRU)
• It favours keeping pages in memory that have
been recently used.
• The OS divides the pages into four classes based
on usage during the last clock tick:
 3. Referenced, modified
 2. Referenced, not modified
 1. Not referenced, modified
 0. Not referenced, not modified
NRU
• Pick a random page from the lowest category for
removal
• i.e. the not referenced, not modified page
NRU Example
Fig: NRU example
Recently
referenced
Hit
Hit Hit Hit Hit Hit
Second Chance
• Modified version of FIFO
• Instead of swapping out the last page, the
referenced bit is checked
• Gives every page a "second-chance"
Fig: Second Chance
Clock
• Modified version of FIFO
• The set of frame candidates for replacement is
considered as a circular buffer.
Fig: CLOCK
Least Recently Used (LRU)
• It swaps the pages that have been used the least
over a period of time.
• It is free from Belady’s anomaly.
LRU Example
Recently
referenced
Hit
Hit Hit Hit Hit Hit
Fig: LRU example
Not frequently used (NFU)
• This page replacement algorithm requires a
counter
• The counters keep track of how frequently a
page has been used
• The page with the lowest counter can be
swapped out
reference sequence : 3 2 3 0 8 4 2 5 0 9 8 3 2
P U 3 P U 2 P U 3 P U 0 P U 8 P U 4
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| | 0 |* | 3 | 1 | | 3 | 1 | | 3 | 1 | | 3 | 1 | | 3 | 1 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| | 0 | | | 0 |* | 2 | 1 | | 2 | 1 | | 2 | 1 | | 2 | 1 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| | 0 | | | 0 | | | 0 |* | | 0 |* | 0 | 1 | | 0 | 1 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| | 0 | | | 0 | | | 0 | | | 0 | | | 0 |* | 8 | 1 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| | 0 | | | 0 | | | 0 | | | 0 | | | 0 | | | 0 |*
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+----
P U 2 P U 5 P U 0 P U 9 P U 8 P U 3
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| 3 | 1 |* | 3 | 1 |* | 5 | 1 | | 5 | 1 | | 5 | 1 | | 5 | 1 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| 2 | 1 | | 2 | 1 | | 2 | 0 |* | 2 | 0 |* | 9 | 1 | | 9 | 1 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| 0 | 1 | | 0 | 1 | | 0 | 0 | | 0 | 1 | | 0 | 1 |* | 0 | 1 |*
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| 8 | 1 | | 8 | 1 | | 8 | 0 | | 8 | 0 | | 8 | 0 | | 8 | 1 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| 4 | 1 | | 4 | 1 | | 4 | 0 | | 4 | 0 | | 4 | 0 | | 4 | 0 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+----
P U 2 P U
+---+---+ +---+---+ * = indicates the pointer which identifies the next location
| 5 | 1 |* | 5 | 0 | to scan P = page# stored in that frame U = used flag
| 9 | 1 | | 9 | 0 | 0 = not used recently 1 = referenced recently
+---+---+ +---+---+
| 0 | 0 | | 2 | 1 |
+---+---+ +---+---+
| 8 | 0 | | 8 | 0 |*
+---+---+ +---+---+
| 3 | 1 | | 3 | 1 |
+---+---+ +---+---+
Fig: NFU example
Random
• This algorithm replaces a random page in
memory.
• It fares better than FIFO.
Working set page replacement
• The set of pages that a process is currently using
is called the working set.
• The working set algorithm is based on
determining a working set and evicting any page
that is not in the current working set upon a
page fault.
Conclusion
Algorithm Comment
• FIFO
• OPTIMAL
• LRU
• NRU
• NFU
• Second Chance
• CLOCK
• Might throw out important
pages
• Not implementable
• Excellent but difficult to
implement
• Crude approximation of LRU
• Crude approximation of LRU
• Big improvement over FIFO
• Realistic
References
• Web Links
 www.wikipedia.com
 www.youtube.com
 www.vbForum.com
• Papers
 Operating System Page Replacement Algorithms by
A. Frank C. Wersberg
• Books
 Computer Organization & Architecture by William
Stallings
Thank You

Contenu connexe

Similaire à pagereplacementalgorithmsa010a011-140520095310-phpapp01.pdf

Highload++2014: 1Hippeus - zerocopy messaging in the spirit of Sparta!
Highload++2014: 1Hippeus - zerocopy messaging in the spirit of Sparta!Highload++2014: 1Hippeus - zerocopy messaging in the spirit of Sparta!
Highload++2014: 1Hippeus - zerocopy messaging in the spirit of Sparta!Leonid Yuriev
 
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 cuPankajKumar790026
 
Need for Speed: MySQL Indexing
Need for Speed: MySQL IndexingNeed for Speed: MySQL Indexing
Need for Speed: MySQL IndexingMYXPLAIN
 
Hashtag cashtagfinal_1
Hashtag cashtagfinal_1Hashtag cashtagfinal_1
Hashtag cashtagfinal_1Shafi Bashar
 
4. Data Manipulation.ppt
4. Data Manipulation.ppt4. Data Manipulation.ppt
4. Data Manipulation.pptKISHOYIANKISH
 
MeetBSD2014 Performance Analysis
MeetBSD2014 Performance AnalysisMeetBSD2014 Performance Analysis
MeetBSD2014 Performance AnalysisBrendan Gregg
 
1Hippeus - zerocopy messaging по законам Спарты, Леонид Юрьев (ПЕТЕР-СЕРВИС)
1Hippeus -  zerocopy messaging по законам Спарты, Леонид Юрьев (ПЕТЕР-СЕРВИС)1Hippeus -  zerocopy messaging по законам Спарты, Леонид Юрьев (ПЕТЕР-СЕРВИС)
1Hippeus - zerocopy messaging по законам Спарты, Леонид Юрьев (ПЕТЕР-СЕРВИС)Ontico
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016Brendan Gregg
 
Homework Assignment 3 Chapter 3 St. Clair & Visick, Putting you.docx
Homework Assignment 3 Chapter 3 St. Clair & Visick, Putting you.docxHomework Assignment 3 Chapter 3 St. Clair & Visick, Putting you.docx
Homework Assignment 3 Chapter 3 St. Clair & Visick, Putting you.docxfideladallimore
 
Performance Enhancements In Postgre Sql 8.4
Performance Enhancements In Postgre Sql 8.4Performance Enhancements In Postgre Sql 8.4
Performance Enhancements In Postgre Sql 8.4HighLoad2009
 
忙しい人のためのSphinx 入門 demo
忙しい人のためのSphinx 入門 demo忙しい人のためのSphinx 入門 demo
忙しい人のためのSphinx 入門 demoFumihito Yokoyama
 
Routing in Fat Trees (RIFT) Open Source Update at IETF-108
Routing in Fat Trees (RIFT) Open Source Update at IETF-108Routing in Fat Trees (RIFT) Open Source Update at IETF-108
Routing in Fat Trees (RIFT) Open Source Update at IETF-108Bruno Rijsman
 
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...Sergey Petrunya
 
How to use histograms to get better performance
How to use histograms to get better performanceHow to use histograms to get better performance
How to use histograms to get better performanceMariaDB plc
 
Using histograms to get better performance
Using histograms to get better performanceUsing histograms to get better performance
Using histograms to get better performanceSergey Petrunya
 
Workshop 20140522 BigQuery Implementation
Workshop 20140522   BigQuery ImplementationWorkshop 20140522   BigQuery Implementation
Workshop 20140522 BigQuery ImplementationSimon Su
 
Adaptive Query Optimization
Adaptive Query OptimizationAdaptive Query Optimization
Adaptive Query OptimizationAnju Garg
 

Similaire à pagereplacementalgorithmsa010a011-140520095310-phpapp01.pdf (20)

Perf Tuning Short
Perf Tuning ShortPerf Tuning Short
Perf Tuning Short
 
Highload++2014: 1Hippeus - zerocopy messaging in the spirit of Sparta!
Highload++2014: 1Hippeus - zerocopy messaging in the spirit of Sparta!Highload++2014: 1Hippeus - zerocopy messaging in the spirit of Sparta!
Highload++2014: 1Hippeus - zerocopy messaging in the spirit of Sparta!
 
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
 
Need for Speed: MySQL Indexing
Need for Speed: MySQL IndexingNeed for Speed: MySQL Indexing
Need for Speed: MySQL Indexing
 
#Cashtag
#Cashtag#Cashtag
#Cashtag
 
Hashtag cashtagfinal_1
Hashtag cashtagfinal_1Hashtag cashtagfinal_1
Hashtag cashtagfinal_1
 
4. Data Manipulation.ppt
4. Data Manipulation.ppt4. Data Manipulation.ppt
4. Data Manipulation.ppt
 
MeetBSD2014 Performance Analysis
MeetBSD2014 Performance AnalysisMeetBSD2014 Performance Analysis
MeetBSD2014 Performance Analysis
 
1Hippeus - zerocopy messaging по законам Спарты, Леонид Юрьев (ПЕТЕР-СЕРВИС)
1Hippeus -  zerocopy messaging по законам Спарты, Леонид Юрьев (ПЕТЕР-СЕРВИС)1Hippeus -  zerocopy messaging по законам Спарты, Леонид Юрьев (ПЕТЕР-СЕРВИС)
1Hippeus - zerocopy messaging по законам Спарты, Леонид Юрьев (ПЕТЕР-СЕРВИС)
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016
 
Homework Assignment 3 Chapter 3 St. Clair & Visick, Putting you.docx
Homework Assignment 3 Chapter 3 St. Clair & Visick, Putting you.docxHomework Assignment 3 Chapter 3 St. Clair & Visick, Putting you.docx
Homework Assignment 3 Chapter 3 St. Clair & Visick, Putting you.docx
 
Performance Enhancements In Postgre Sql 8.4
Performance Enhancements In Postgre Sql 8.4Performance Enhancements In Postgre Sql 8.4
Performance Enhancements In Postgre Sql 8.4
 
忙しい人のためのSphinx 入門 demo
忙しい人のためのSphinx 入門 demo忙しい人のためのSphinx 入門 demo
忙しい人のためのSphinx 入門 demo
 
Routing in Fat Trees (RIFT) Open Source Update at IETF-108
Routing in Fat Trees (RIFT) Open Source Update at IETF-108Routing in Fat Trees (RIFT) Open Source Update at IETF-108
Routing in Fat Trees (RIFT) Open Source Update at IETF-108
 
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
 
How to use histograms to get better performance
How to use histograms to get better performanceHow to use histograms to get better performance
How to use histograms to get better performance
 
Using histograms to get better performance
Using histograms to get better performanceUsing histograms to get better performance
Using histograms to get better performance
 
Subquery factoring for FTS
Subquery factoring for FTSSubquery factoring for FTS
Subquery factoring for FTS
 
Workshop 20140522 BigQuery Implementation
Workshop 20140522   BigQuery ImplementationWorkshop 20140522   BigQuery Implementation
Workshop 20140522 BigQuery Implementation
 
Adaptive Query Optimization
Adaptive Query OptimizationAdaptive Query Optimization
Adaptive Query Optimization
 

Dernier

Brand experience Dream Center Peoria Presentation.pdf
Brand experience Dream Center Peoria Presentation.pdfBrand experience Dream Center Peoria Presentation.pdf
Brand experience Dream Center Peoria Presentation.pdftbatkhuu1
 
How to Leverage Behavioral Science Insights for Direct Mail Success
How to Leverage Behavioral Science Insights for Direct Mail SuccessHow to Leverage Behavioral Science Insights for Direct Mail Success
How to Leverage Behavioral Science Insights for Direct Mail SuccessAggregage
 
The+State+of+Careers+In+Retention+Marketing-2.pdf
The+State+of+Careers+In+Retention+Marketing-2.pdfThe+State+of+Careers+In+Retention+Marketing-2.pdf
The+State+of+Careers+In+Retention+Marketing-2.pdfSocial Samosa
 
Branding strategies of new company .pptx
Branding strategies of new company .pptxBranding strategies of new company .pptx
Branding strategies of new company .pptxVikasTiwari846641
 
FULL ENJOY Call Girls In Majnu.Ka.Tilla Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu.Ka.Tilla Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu.Ka.Tilla Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu.Ka.Tilla Delhi Contact Us 8377877756dollysharma2066
 
BDSM⚡Call Girls in Sector 150 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 150 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 150 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 150 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
BDSM⚡Call Girls in Sector 144 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 144 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 144 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 144 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
Netflix Ads The Game Changer in Video Ads – Who Needs YouTube.pptx (Chester Y...
Netflix Ads The Game Changer in Video Ads – Who Needs YouTube.pptx (Chester Y...Netflix Ads The Game Changer in Video Ads – Who Needs YouTube.pptx (Chester Y...
Netflix Ads The Game Changer in Video Ads – Who Needs YouTube.pptx (Chester Y...ChesterYang6
 
Brand experience Peoria City Soccer Presentation.pdf
Brand experience Peoria City Soccer Presentation.pdfBrand experience Peoria City Soccer Presentation.pdf
Brand experience Peoria City Soccer Presentation.pdftbatkhuu1
 
Situation Analysis | Management Company.
Situation Analysis | Management Company.Situation Analysis | Management Company.
Situation Analysis | Management Company.DanielaQuiroz63
 
Major SEO Trends in 2024 - Banyanbrain Digital
Major SEO Trends in 2024 - Banyanbrain DigitalMajor SEO Trends in 2024 - Banyanbrain Digital
Major SEO Trends in 2024 - Banyanbrain DigitalBanyanbrain
 
Unraveling the Mystery of The Circleville Letters.pptx
Unraveling the Mystery of The Circleville Letters.pptxUnraveling the Mystery of The Circleville Letters.pptx
Unraveling the Mystery of The Circleville Letters.pptxelizabethella096
 
Google 3rd-Party Cookie Deprecation [Update] + 5 Best Strategies
Google 3rd-Party Cookie Deprecation [Update] + 5 Best StrategiesGoogle 3rd-Party Cookie Deprecation [Update] + 5 Best Strategies
Google 3rd-Party Cookie Deprecation [Update] + 5 Best StrategiesSearch Engine Journal
 

Dernier (20)

Brand experience Dream Center Peoria Presentation.pdf
Brand experience Dream Center Peoria Presentation.pdfBrand experience Dream Center Peoria Presentation.pdf
Brand experience Dream Center Peoria Presentation.pdf
 
LinkedIn Social Selling Master Class - David Wong
LinkedIn Social Selling Master Class - David WongLinkedIn Social Selling Master Class - David Wong
LinkedIn Social Selling Master Class - David Wong
 
How to Leverage Behavioral Science Insights for Direct Mail Success
How to Leverage Behavioral Science Insights for Direct Mail SuccessHow to Leverage Behavioral Science Insights for Direct Mail Success
How to Leverage Behavioral Science Insights for Direct Mail Success
 
How to Create a Social Media Plan Like a Pro - Jordan Scheltgen
How to Create a Social Media Plan Like a Pro - Jordan ScheltgenHow to Create a Social Media Plan Like a Pro - Jordan Scheltgen
How to Create a Social Media Plan Like a Pro - Jordan Scheltgen
 
The+State+of+Careers+In+Retention+Marketing-2.pdf
The+State+of+Careers+In+Retention+Marketing-2.pdfThe+State+of+Careers+In+Retention+Marketing-2.pdf
The+State+of+Careers+In+Retention+Marketing-2.pdf
 
Branding strategies of new company .pptx
Branding strategies of new company .pptxBranding strategies of new company .pptx
Branding strategies of new company .pptx
 
FULL ENJOY Call Girls In Majnu.Ka.Tilla Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu.Ka.Tilla Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu.Ka.Tilla Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu.Ka.Tilla Delhi Contact Us 8377877756
 
BDSM⚡Call Girls in Sector 150 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 150 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 150 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 150 Noida Escorts >༒8448380779 Escort Service
 
Digital Strategy Master Class - Andrew Rupert
Digital Strategy Master Class - Andrew RupertDigital Strategy Master Class - Andrew Rupert
Digital Strategy Master Class - Andrew Rupert
 
Top 5 Breakthrough AI Innovations Elevating Content Creation and Personalizat...
Top 5 Breakthrough AI Innovations Elevating Content Creation and Personalizat...Top 5 Breakthrough AI Innovations Elevating Content Creation and Personalizat...
Top 5 Breakthrough AI Innovations Elevating Content Creation and Personalizat...
 
BDSM⚡Call Girls in Sector 144 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 144 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 144 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 144 Noida Escorts >༒8448380779 Escort Service
 
Turn Digital Reputation Threats into Offense Tactics - Daniel Lemin
Turn Digital Reputation Threats into Offense Tactics - Daniel LeminTurn Digital Reputation Threats into Offense Tactics - Daniel Lemin
Turn Digital Reputation Threats into Offense Tactics - Daniel Lemin
 
SEO Master Class - Steve Wiideman, Wiideman Consulting Group
SEO Master Class - Steve Wiideman, Wiideman Consulting GroupSEO Master Class - Steve Wiideman, Wiideman Consulting Group
SEO Master Class - Steve Wiideman, Wiideman Consulting Group
 
Netflix Ads The Game Changer in Video Ads – Who Needs YouTube.pptx (Chester Y...
Netflix Ads The Game Changer in Video Ads – Who Needs YouTube.pptx (Chester Y...Netflix Ads The Game Changer in Video Ads – Who Needs YouTube.pptx (Chester Y...
Netflix Ads The Game Changer in Video Ads – Who Needs YouTube.pptx (Chester Y...
 
Brand experience Peoria City Soccer Presentation.pdf
Brand experience Peoria City Soccer Presentation.pdfBrand experience Peoria City Soccer Presentation.pdf
Brand experience Peoria City Soccer Presentation.pdf
 
Creator Influencer Strategy Master Class - Corinne Rose Guirgis
Creator Influencer Strategy Master Class - Corinne Rose GuirgisCreator Influencer Strategy Master Class - Corinne Rose Guirgis
Creator Influencer Strategy Master Class - Corinne Rose Guirgis
 
Situation Analysis | Management Company.
Situation Analysis | Management Company.Situation Analysis | Management Company.
Situation Analysis | Management Company.
 
Major SEO Trends in 2024 - Banyanbrain Digital
Major SEO Trends in 2024 - Banyanbrain DigitalMajor SEO Trends in 2024 - Banyanbrain Digital
Major SEO Trends in 2024 - Banyanbrain Digital
 
Unraveling the Mystery of The Circleville Letters.pptx
Unraveling the Mystery of The Circleville Letters.pptxUnraveling the Mystery of The Circleville Letters.pptx
Unraveling the Mystery of The Circleville Letters.pptx
 
Google 3rd-Party Cookie Deprecation [Update] + 5 Best Strategies
Google 3rd-Party Cookie Deprecation [Update] + 5 Best StrategiesGoogle 3rd-Party Cookie Deprecation [Update] + 5 Best Strategies
Google 3rd-Party Cookie Deprecation [Update] + 5 Best Strategies
 

pagereplacementalgorithmsa010a011-140520095310-phpapp01.pdf

  • 2. Index 1. Paging 2. Page Replacement 3. Algorithms 4. Conclusion 5. References Topic S. No. a. Optimal b. FIFO c. NFU d. NRU e. LRU f. Second Chance g. CLOCK h. Random i. Working Set i
  • 3. Plan of Action • What is paging? • What is page replacement? • What are the types of page replacement? • Why we need a page replacement algorithm? • What are the algorithms?
  • 4. What is Paging? • The OS divides virtual memory and the main memory into units, called pages. • Each used page can be either in secondary memory or in a page frame in main memory. • A frame does not have to comprise a single physically contiguous region in secondary storage.
  • 5. What is page replacement? • When memory located in secondary memory is needed, it can be retrieved back to main memory. • Process of storing data from main memory to secondary memory ->swapping out • Retrieving data back to main memory ->swapping in
  • 7. What are Page Replacement Algorithms? • Deals with which pages need to be swapped out and which are the ones that need to be swapped in • The efficiency lies in the least time that is wasted for a page to be paged in
  • 8. Types • Local Page Replacement Strategy • Global Page Replacement Strategy
  • 9. Why we need a page replacement algorithm? • The main goal of page replacement algorithms is to provide lowest page fault rate.
  • 11. No. of Page Faults Vs No. of Frames
  • 12. Algorithms • First In First Out • Optimal Replacement • Not Recently Used • Second Chance • CLOCK • Not Frequently Used • Least Recently Used • Random Replacement • Working Set Replacement
  • 13. First-In First-Out (FIFO) • Pages in main memory are kept in a list • Newest page is in head and the oldest in tail • It does not take advantage of page access patterns or frequency
  • 15. FIFO Example Oldest Hit Hit Hit Newest Fig: FIFO example
  • 16. Optimal Replacement (OPT) • When the memory is full, evict a page that will be unreferenced for the longest time • The OS keeps track of all pages referenced by the program • Only if the program's memory reference pattern is relatively consistent
  • 17. OPTIMAL Example Referenced last Hit Hit Hit Hit Hit Hit Fig: OPTIMAL example
  • 18. Not Recently Used (NRU) • It favours keeping pages in memory that have been recently used. • The OS divides the pages into four classes based on usage during the last clock tick:  3. Referenced, modified  2. Referenced, not modified  1. Not referenced, modified  0. Not referenced, not modified
  • 19. NRU • Pick a random page from the lowest category for removal • i.e. the not referenced, not modified page
  • 20. NRU Example Fig: NRU example Recently referenced Hit Hit Hit Hit Hit Hit
  • 21. Second Chance • Modified version of FIFO • Instead of swapping out the last page, the referenced bit is checked • Gives every page a "second-chance"
  • 23. Clock • Modified version of FIFO • The set of frame candidates for replacement is considered as a circular buffer.
  • 25. Least Recently Used (LRU) • It swaps the pages that have been used the least over a period of time. • It is free from Belady’s anomaly.
  • 26. LRU Example Recently referenced Hit Hit Hit Hit Hit Hit Fig: LRU example
  • 27. Not frequently used (NFU) • This page replacement algorithm requires a counter • The counters keep track of how frequently a page has been used • The page with the lowest counter can be swapped out
  • 28. reference sequence : 3 2 3 0 8 4 2 5 0 9 8 3 2 P U 3 P U 2 P U 3 P U 0 P U 8 P U 4 +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ | | 0 |* | 3 | 1 | | 3 | 1 | | 3 | 1 | | 3 | 1 | | 3 | 1 | +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ | | 0 | | | 0 |* | 2 | 1 | | 2 | 1 | | 2 | 1 | | 2 | 1 | +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ | | 0 | | | 0 | | | 0 |* | | 0 |* | 0 | 1 | | 0 | 1 | +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ | | 0 | | | 0 | | | 0 | | | 0 | | | 0 |* | 8 | 1 | +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ | | 0 | | | 0 | | | 0 | | | 0 | | | 0 | | | 0 |* +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---- P U 2 P U 5 P U 0 P U 9 P U 8 P U 3 +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ | 3 | 1 |* | 3 | 1 |* | 5 | 1 | | 5 | 1 | | 5 | 1 | | 5 | 1 | +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ | 2 | 1 | | 2 | 1 | | 2 | 0 |* | 2 | 0 |* | 9 | 1 | | 9 | 1 | +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ | 0 | 1 | | 0 | 1 | | 0 | 0 | | 0 | 1 | | 0 | 1 |* | 0 | 1 |* +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ | 8 | 1 | | 8 | 1 | | 8 | 0 | | 8 | 0 | | 8 | 0 | | 8 | 1 | +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ | 4 | 1 | | 4 | 1 | | 4 | 0 | | 4 | 0 | | 4 | 0 | | 4 | 0 | +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---- P U 2 P U +---+---+ +---+---+ * = indicates the pointer which identifies the next location | 5 | 1 |* | 5 | 0 | to scan P = page# stored in that frame U = used flag | 9 | 1 | | 9 | 0 | 0 = not used recently 1 = referenced recently +---+---+ +---+---+ | 0 | 0 | | 2 | 1 | +---+---+ +---+---+ | 8 | 0 | | 8 | 0 |* +---+---+ +---+---+ | 3 | 1 | | 3 | 1 | +---+---+ +---+---+ Fig: NFU example
  • 29. Random • This algorithm replaces a random page in memory. • It fares better than FIFO.
  • 30. Working set page replacement • The set of pages that a process is currently using is called the working set. • The working set algorithm is based on determining a working set and evicting any page that is not in the current working set upon a page fault.
  • 31.
  • 32. Conclusion Algorithm Comment • FIFO • OPTIMAL • LRU • NRU • NFU • Second Chance • CLOCK • Might throw out important pages • Not implementable • Excellent but difficult to implement • Crude approximation of LRU • Crude approximation of LRU • Big improvement over FIFO • Realistic
  • 33. References • Web Links  www.wikipedia.com  www.youtube.com  www.vbForum.com • Papers  Operating System Page Replacement Algorithms by A. Frank C. Wersberg • Books  Computer Organization & Architecture by William Stallings