SlideShare a Scribd company logo
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.
Page replacement algorithms
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
Ad

More Related Content

What's hot (20)

DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
Venkata Sreeram
 
File allocation methods (1)
File allocation methods (1)File allocation methods (1)
File allocation methods (1)
Dr. Jasmine Beulah Gnanadurai
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
Kumar Pritam
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
Poojith Chowdhary
 
Free space managment46
Free space managment46Free space managment46
Free space managment46
myrajendra
 
Chapter 13 - I/O Systems
Chapter 13 - I/O SystemsChapter 13 - I/O Systems
Chapter 13 - I/O Systems
Wayne Jones Jnr
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
Ravi Kumar Patel
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
rprajat007
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
Prakhar Maurya
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
Dhaval Sakhiya
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System Implementation
Wayne Jones Jnr
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
Adeel Rasheed
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
NEERAJ BAGHEL
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Ninad Mankar
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
koolkampus
 
File system structure
File system structureFile system structure
File system structure
sangrampatil81
 
File access method
File access methodFile access method
File access method
GayathriS578276
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
Tech_MX
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
Nishant Joshi
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
koolkampus
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
Venkata Sreeram
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
Kumar Pritam
 
Free space managment46
Free space managment46Free space managment46
Free space managment46
myrajendra
 
Chapter 13 - I/O Systems
Chapter 13 - I/O SystemsChapter 13 - I/O Systems
Chapter 13 - I/O Systems
Wayne Jones Jnr
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
Ravi Kumar Patel
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
rprajat007
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
Prakhar Maurya
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System Implementation
Wayne Jones Jnr
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
Adeel Rasheed
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Ninad Mankar
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
koolkampus
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
Tech_MX
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
Nishant Joshi
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
koolkampus
 

Viewers also liked (11)

Translation lookaside buffer
Translation lookaside bufferTranslation lookaside buffer
Translation lookaside buffer
Chetan Mahawar
 
41 page replacement fifo
41 page replacement fifo41 page replacement fifo
41 page replacement fifo
myrajendra
 
Page replacement
Page replacementPage replacement
Page replacement
Davin Abraham
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43
myrajendra
 
Handling Page Fault
Handling Page FaultHandling Page Fault
Handling Page Fault
guestb7dc8e
 
Faults
FaultsFaults
Faults
RAHUL SINHA
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
Gopikrishna Madanan
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
Wayne Jones Jnr
 
Page replacement
Page replacementPage replacement
Page replacement
sashi799
 
Page Replacement
Page ReplacementPage Replacement
Page Replacement
chandinisanz
 
1327 Addressing Modes Of 8086
1327 Addressing Modes Of 80861327 Addressing Modes Of 8086
1327 Addressing Modes Of 8086
techbed
 
Translation lookaside buffer
Translation lookaside bufferTranslation lookaside buffer
Translation lookaside buffer
Chetan Mahawar
 
41 page replacement fifo
41 page replacement fifo41 page replacement fifo
41 page replacement fifo
myrajendra
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43
myrajendra
 
Handling Page Fault
Handling Page FaultHandling Page Fault
Handling Page Fault
guestb7dc8e
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
Wayne Jones Jnr
 
Page replacement
Page replacementPage replacement
Page replacement
sashi799
 
1327 Addressing Modes Of 8086
1327 Addressing Modes Of 80861327 Addressing Modes Of 8086
1327 Addressing Modes Of 8086
techbed
 
Ad

Similar to Page replacement algorithms (20)

Percona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuningPercona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuning
Sergey Petrunya
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfz
Joshua 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 Performance
oysteing
 
Computer architecture page replacement algorithms
Computer architecture page replacement algorithmsComputer architecture page replacement algorithms
Computer architecture page replacement algorithms
Mazin Alwaaly
 
Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Window functions in MariaDB 10.2
Window functions in MariaDB 10.2
Sergey Petrunya
 
Virtual memory and page replacement algorithm
Virtual memory and page replacement algorithmVirtual memory and page replacement algorithm
Virtual memory and page replacement algorithm
Muhammad 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 PostgreSQL
Mark Wong
 
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
Command Prompt., Inc
 
Perf Tuning Short
Perf Tuning ShortPerf Tuning Short
Perf Tuning Short
Ligaya Turmelle
 
Explain about replacement algorithms from these slides
Explain about replacement algorithms from these slidesExplain about replacement algorithms from these slides
Explain about replacement algorithms from these slides
ssusera979f41
 
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
PankajKumar790026
 
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.ppt
KISHOYIANKISH
 
Need for Speed: MySQL Indexing
Need for Speed: MySQL IndexingNeed for Speed: MySQL Indexing
Need for Speed: MySQL Indexing
MYXPLAIN
 
#Cashtag
#Cashtag#Cashtag
#Cashtag
Shafi Bashar
 
Hashtag cashtagfinal_1
Hashtag cashtagfinal_1Hashtag cashtagfinal_1
Hashtag cashtagfinal_1
Shafi Bashar
 
MeetBSD2014 Performance Analysis
MeetBSD2014 Performance AnalysisMeetBSD2014 Performance Analysis
MeetBSD2014 Performance Analysis
Brendan 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.docx
fideladallimore
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016
Brendan Gregg
 
Percona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuningPercona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuning
Sergey Petrunya
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfz
Joshua 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 Performance
oysteing
 
Computer architecture page replacement algorithms
Computer architecture page replacement algorithmsComputer architecture page replacement algorithms
Computer architecture page replacement algorithms
Mazin Alwaaly
 
Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Window functions in MariaDB 10.2
Window functions in MariaDB 10.2
Sergey Petrunya
 
Virtual memory and page replacement algorithm
Virtual memory and page replacement algorithmVirtual memory and page replacement algorithm
Virtual memory and page replacement algorithm
Muhammad 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 PostgreSQL
Mark Wong
 
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
Command Prompt., Inc
 
Explain about replacement algorithms from these slides
Explain about replacement algorithms from these slidesExplain about replacement algorithms from these slides
Explain about replacement algorithms from these slides
ssusera979f41
 
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
PankajKumar790026
 
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.ppt
KISHOYIANKISH
 
Need for Speed: MySQL Indexing
Need for Speed: MySQL IndexingNeed for Speed: MySQL Indexing
Need for Speed: MySQL Indexing
MYXPLAIN
 
Hashtag cashtagfinal_1
Hashtag cashtagfinal_1Hashtag cashtagfinal_1
Hashtag cashtagfinal_1
Shafi Bashar
 
MeetBSD2014 Performance Analysis
MeetBSD2014 Performance AnalysisMeetBSD2014 Performance Analysis
MeetBSD2014 Performance Analysis
Brendan 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.docx
fideladallimore
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016
Brendan Gregg
 
Ad

More from Piyush Rochwani (20)

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

Recently uploaded (20)

114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf
paulinelee52
 
Conditions for Boltzmann Law – Biophysics Lecture Slide
Conditions for Boltzmann Law – Biophysics Lecture SlideConditions for Boltzmann Law – Biophysics Lecture Slide
Conditions for Boltzmann Law – Biophysics Lecture Slide
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
The History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.pptThe History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.ppt
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
Quiz Club of PSG College of Arts & Science
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdfGENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
Quiz Club of PSG College of Arts & Science
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
ITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQ
SONU HEETSON
 
MICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdfMICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdf
DHARMENDRA SAHU
 
Cyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top QuestionsCyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top Questions
SONU HEETSON
 
How to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 SalesHow to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 Sales
Celine George
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
materi 3D Augmented Reality dengan assemblr
materi 3D Augmented Reality dengan assemblrmateri 3D Augmented Reality dengan assemblr
materi 3D Augmented Reality dengan assemblr
fatikhatunnajikhah1
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf
paulinelee52
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
ITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQ
SONU HEETSON
 
MICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdfMICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdf
DHARMENDRA SAHU
 
Cyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top QuestionsCyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top Questions
SONU HEETSON
 
How to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 SalesHow to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 Sales
Celine George
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
materi 3D Augmented Reality dengan assemblr
materi 3D Augmented Reality dengan assemblrmateri 3D Augmented Reality dengan assemblr
materi 3D Augmented Reality dengan assemblr
fatikhatunnajikhah1
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 

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.
  • 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

Editor's Notes

  • #5: may exceed the amount of main memory-> virtual memory active part in main memory and the rest in secondary memory Data read in pages
  • #9:  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.
  • #12: Belady’s anamoly-page fault inc with no. of frames
  • #16: Disadvantage->page that is referenced frequently also gets replaced->doesn’t take care of that belady’s anamoly
  • #17: Covers up the disadvantage of FIFO Unreferenced for the longest time->replace that page Os will keep track->pattern should be consistent
  • #18: Free of belady’s anamoly
  • #19: Covers up the disadvantage of FIFO Instead of
  • #21: Free from belady’s anamoly
  • #26: LRU keeps track of page usage over a short period of time, while NRU just looks at the usage in the last clock interval.
  • #27: Free from belady’s anamoly
  翻译: