SlideShare uma empresa Scribd logo
1 de 34
Page Replacement Algorithms
FIFO, NRU, LRU, NFU...
Index
S. No. Topic
1. Paging
2. Page Replacement
3. Algorithms
a. Optimal
b. FIFO
c. NFU
d. NRU
e. LRU
f. Second Chance
g. CLOCK
h. Random
i. Working Set
4. Conclusion
5. References
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?
yesno
HITFAULT
STOPFetch 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 HitHit 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

Mais conteúdo relacionado

Mais procurados

linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure shameen khan
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.CS_GDRCST
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memorysgpraju
 
Cache memory
Cache memoryCache memory
Cache memoryAnuj Modi
 
15 puzzle problem using branch and bound
15 puzzle problem using branch and bound15 puzzle problem using branch and bound
15 puzzle problem using branch and boundAbhishek Singh
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating SystemsRitu Ranjan Shrivastwa
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)Prakhar Maurya
 
Asynchronous data transfer
Asynchronous data transferAsynchronous data transfer
Asynchronous data transferpriya Nithya
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stackAsif Iqbal
 

Mais procurados (20)

Memory management
Memory managementMemory management
Memory management
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Parallel processing
Parallel processingParallel processing
Parallel processing
 
Database recovery
Database recoveryDatabase recovery
Database recovery
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
File allocation methods (1)
File allocation methods (1)File allocation methods (1)
File allocation methods (1)
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
single linked list
single linked listsingle linked list
single linked list
 
operating system structure
operating system structureoperating system structure
operating system structure
 
Memory Hierarchy
Memory HierarchyMemory Hierarchy
Memory Hierarchy
 
15 puzzle problem using branch and bound
15 puzzle problem using branch and bound15 puzzle problem using branch and bound
15 puzzle problem using branch and bound
 
operating system lecture notes
operating system lecture notesoperating system lecture notes
operating system lecture notes
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Asynchronous data transfer
Asynchronous data transferAsynchronous data transfer
Asynchronous data transfer
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stack
 

Destaque

Translation lookaside buffer
Translation lookaside bufferTranslation lookaside buffer
Translation lookaside bufferChetan Mahawar
 
41 page replacement fifo
41 page replacement fifo41 page replacement fifo
41 page replacement fifomyrajendra
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43myrajendra
 
Handling Page Fault
Handling Page FaultHandling Page Fault
Handling Page Faultguestb7dc8e
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryWayne Jones Jnr
 
Page replacement
Page replacementPage replacement
Page replacementsashi799
 
1327 Addressing Modes Of 8086
1327 Addressing Modes Of 80861327 Addressing Modes Of 8086
1327 Addressing Modes Of 8086techbed
 

Destaque (11)

Translation lookaside buffer
Translation lookaside bufferTranslation lookaside buffer
Translation lookaside buffer
 
41 page replacement fifo
41 page replacement fifo41 page replacement fifo
41 page replacement fifo
 
Page replacement
Page replacementPage replacement
Page replacement
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43
 
Handling Page Fault
Handling Page FaultHandling Page Fault
Handling Page Fault
 
Faults
FaultsFaults
Faults
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
 
Page replacement
Page replacementPage replacement
Page replacement
 
Page Replacement
Page ReplacementPage Replacement
Page Replacement
 
1327 Addressing Modes Of 8086
1327 Addressing Modes Of 80861327 Addressing Modes Of 8086
1327 Addressing Modes Of 8086
 

Semelhante a Page replacement algorithms

Percona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuningPercona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuningSergey Petrunya
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfzJoshua Thijssen
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performanceoysteing
 
Computer architecture page replacement algorithms
Computer architecture page replacement algorithmsComputer architecture page replacement algorithms
Computer architecture page replacement algorithmsMazin Alwaaly
 
Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Sergey Petrunya
 
Virtual memory and page replacement algorithm
Virtual memory and page replacement algorithmVirtual memory and page replacement algorithm
Virtual memory and page replacement algorithmMuhammad Mansoor Ul Haq
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLCommand Prompt., Inc
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLMark Wong
 
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
 
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
 
4. Data Manipulation.ppt
4. Data Manipulation.ppt4. Data Manipulation.ppt
4. Data Manipulation.pptKISHOYIANKISH
 
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
 
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
 
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
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016Brendan Gregg
 
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
 

Semelhante a Page replacement algorithms (20)

Percona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuningPercona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuning
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfz
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
 
Computer architecture page replacement algorithms
Computer architecture page replacement algorithmsComputer architecture page replacement algorithms
Computer architecture page replacement algorithms
 
Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Window functions in MariaDB 10.2
Window functions in MariaDB 10.2
 
Virtual memory and page replacement algorithm
Virtual memory and page replacement algorithmVirtual memory and page replacement algorithm
Virtual memory and page replacement algorithm
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
Perf Tuning Short
Perf Tuning ShortPerf Tuning Short
Perf Tuning Short
 
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
 
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!
 
4. Data Manipulation.ppt
4. Data Manipulation.ppt4. Data Manipulation.ppt
4. Data Manipulation.ppt
 
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
 
MeetBSD2014 Performance Analysis
MeetBSD2014 Performance AnalysisMeetBSD2014 Performance Analysis
MeetBSD2014 Performance Analysis
 
1Hippeus - zerocopy messaging по законам Спарты, Леонид Юрьев (ПЕТЕР-СЕРВИС)
1Hippeus -  zerocopy messaging по законам Спарты, Леонид Юрьев (ПЕТЕР-СЕРВИС)1Hippeus -  zerocopy messaging по законам Спарты, Леонид Юрьев (ПЕТЕР-СЕРВИС)
1Hippeus - zerocopy messaging по законам Спарты, Леонид Юрьев (ПЕТЕР-СЕРВИС)
 
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
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016
 
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
 

Mais de Piyush Rochwani (20)

Unit 2
Unit 2Unit 2
Unit 2
 
Unit 3
Unit 3Unit 3
Unit 3
 
Biometrics based key generation
Biometrics based key generationBiometrics based key generation
Biometrics based key generation
 
Serial transmission
Serial transmissionSerial transmission
Serial transmission
 
Sequential and combinational alu
Sequential and combinational alu Sequential and combinational alu
Sequential and combinational alu
 
Memory virtualization
Memory virtualizationMemory virtualization
Memory virtualization
 
Risc
RiscRisc
Risc
 
Raid
Raid Raid
Raid
 
Pipelining and co processor.
Pipelining and co processor.Pipelining and co processor.
Pipelining and co processor.
 
8086 Microprocessor
8086 Microprocessor8086 Microprocessor
8086 Microprocessor
 
Dma
DmaDma
Dma
 
Control unit
Control unitControl unit
Control unit
 
Memory types
Memory typesMemory types
Memory types
 
Solid state solid state drives
Solid state solid state drivesSolid state solid state drives
Solid state solid state drives
 
Coa INTERUPT
Coa INTERUPTCoa INTERUPT
Coa INTERUPT
 
Cisc(a022& a023)
Cisc(a022& a023)Cisc(a022& a023)
Cisc(a022& a023)
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)
 
06 floating point
06 floating point06 floating point
06 floating point
 
05 multiply divide
05 multiply divide05 multiply divide
05 multiply divide
 
Air pollution in mumbai
Air pollution in mumbaiAir pollution in mumbai
Air pollution in mumbai
 

Último

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
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
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 

Último (20)

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
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
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Page replacement algorithms

  • 2. Index S. No. Topic 1. Paging 2. Page Replacement 3. Algorithms a. Optimal b. FIFO c. NFU d. NRU e. LRU f. Second Chance g. CLOCK h. Random i. Working Set 4. Conclusion 5. References
  • 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 HitHit 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

Notas do Editor

  1. may exceed the amount of main memory-> virtual memory active part in main memory and the rest in secondary memory Data read in pages
  2.  a local page replacement algorithm selects for replacement some page that belongs to that same process (or a group of processes sharing a memory partition). A global replacement algorithm is free to select any page in memory.
  3. Belady’s anamoly-page fault inc with no. of frames
  4. Disadvantage->page that is referenced frequently also gets replaced->doesn’t take care of that belady’s anamoly
  5. Covers up the disadvantage of FIFO Unreferenced for the longest time->replace that page Os will keep track->pattern should be consistent
  6. Free of belady’s anamoly
  7. Covers up the disadvantage of FIFO Instead of
  8. Free from belady’s anamoly
  9. LRU keeps track of page usage over a short period of time, while NRU just looks at the usage in the last clock interval.
  10. Free from belady’s anamoly