SlideShare a Scribd company logo
1 of 41
Plan of Action
• What is paging?
• Page frame and hit ratio ?
• What is page replacement?
• Why we need a page replacement algorithm?
• What are the algorithms?
• In computer operating systems, paging is one of
the memory-management schemes by which a
computer can store and retrieve data from
secondary storage for use in main memory.
• In the paging memory-management scheme, the
operating system retrieves data from secondary
storage in same-size blocks called pages.
• Advantage:
• is that it allows the physical address space of a
process to be non-contiguous.
• Before paging came into use, systems had to fit
whole programs into storage contiguously, which
caused
various storage and fragmentation problems.
• Page Frame: - The main memory is divided into
fixed sized portions called page frame.
• The size of page frame is same as the size of
page because pages have to reside in page
frames.
• Hit Ratio: - The ratio of the total number of hit
divided by the total CPU access to memory (i.e.
hits plus misses) is called hit ratio.
• Hit ratio=total number of hits
total number f hits + total number of mis
A page fault (sometimes called #PF, PF or hard
fault)
is a type of interrupt, called trap, raised by computer
hardware when a running program accesses a memory
page that is mapped into the virtual address space, but
not actually loaded into main memory. The hardware
that detects a page fault is the processor's memory
management unit (MMU), and transfers control from
the program to the operating system.
The operating system must:
• Obtain an empty page frame in RAM to use
as a container for the data.
• Load the requested data into the available
page frame.
• Update the page table to refer to the new
page frame.
• Return control to the program.
• When all page frames are in use, the
operating system must select the page frame
to reuse for the page the program now
needs., which is its page replacement
algorithm.
• 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
• 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
• First In First Out.
• Optimal Replacement.
• Second Chance.
• The Clock Algorithm.
• Least Recently Used.
• Least frquently Used.
• Not Recently Used.
• ARC(adaptive replacement cache).
• CAR(Clock adaptive replacement ).
)
• Pages in main memory are kept in a list
• First in first out is very easy to implement
• The fifo algorithm select the page for
replacement that has been in memory the
longest time
FIFO Example
Oldest
Hit Hit Hit
Newest
Fig: FIFO example
▫ FIFO is easy to understand.
▫ It is very easy to implement.
• The oldest block in memory may be often
used.
• The optimal policy selects that page for replacement
that will not be needed for the longest time
• The OS keeps track of all pages referenced by the
program
• This algorithm result is fewest number of page
faults.
• Advantages
▫ Optimal.
• Disadvantages
▫ Impossible to implement (need to know the
future) but serves as a standard to compare with
the other algorithms.
OPTIMAL Example
Referenced last
Hit Hit HitHit Hit Hit
Fig: OPTIMAL example
• Pages kept in a linked list
▫ Oldest is at the front of the list
• Look at the oldest page
▫ If its “referenced bit” is 0...
 Select it for replacement
▫ Else
 It was used recently; don’t want to replace it
 Clear its “referenced bit”
 Move it to the end of the list
▫ Repeat
• What if every page was used in last clock tick?
▫ Select a page at random
• Better performance than FIFO.
• Not practical (evicted block may be needed in a
short time later).
• Variant of FIFO & LRU
• Keep frames in circle
• On page fault, OS:
• Checks reference bit of next frame
• If reference bit = 0, replace page, set bit to 1
• If reference bit = 1, set bit to 0, advance
pointer to next frame
Fig: CLOCK
• Easy to implement.
• Not practical (evicted block may be needed
in a short time later).
• Not scan resistant.
• The least recently used page replacement
algorithm keeps track page uses over a
short period of time.
LRU Example
Recently
referenced
Hit
Hit Hit Hit Hit Hit
Fig: LRU example
▫ LRU page replacement algorithm is quiet
efficient.
▫ Implementation difficult. This algorithm
requires keeping track of what was used when,
which is expensive if one wants to make sure
the algorithm always discards the least
recently used item.
Comparison of Clock with FIFO and LRU (1)
Fixed-Allocation, Local Page Replacement
 The Least-Frequently-Used (LFU) Replacement
technique replaces the least-frequently block in use
when an eviction must take place.
 Software counter associated with each block, initially
zero is required in this algorithm.
 The operating system checks all the blocks in the
cache at each clock interrupt.
 The R bit, which is '0' or '1', is added to the ounter for
each block. Consequently, the counters are an effort
to keep track of the frequency of referencing each
block.
 When a block must be replaced, the block that has the
lowest counter is selected for the replacement.
• Frequently used block will stay longer than
(fifo)
 Older blocks are less likely to be removed , even
if they are on longer frequently used because this
algorithm never forgets anything.
 Newer blocks are more likely to be replaced even
if they are frequently used.
 Captures only frequency factor.
.
This algorithm requires that each page have
two additional status bits 'R' and 'M' called
reference bit and change bit respectively. The
reference bit(R) is automatically set to 1
whenever the page is referenced. The change
bit (M) is set to 1 whenever the page is
modified. These bits are stored in the PMT
and are updated on every memory reference.
• When a page fault occurs, the memory manager
inspects all the pages and divides them into 4
classes based on R and M bits.
▫ Class 1: (0,0) − neither recently used nor
modified - the best page to replace.
▫ Class 2: (0,1) − not recently used but modified -
the page will need to be written out before
replacement.
▫ Class 3: (1,0) − recently used but clean -
probably will be used again soon.
▫ Class 4: (1,1) − recently used and modified -
probably will be used again, and write out will be
needed before replacing it.
( )
• Advantages?
▫ It is easy to understand.
▫ It is efficient to implement.
▫ Much better behavior than FIFO
▫ Frequently used pages are much more likely to
stay
• Disadvantages?
▫ Behavior sucks near clock cycles
• ARC is used (4) linked lists:
• T1, for recent cache entries.
• T2, for frequent entries, referenced at least twice.
• B1, ghost entries recently evicted from the T1 cache,
but are still tracked.
• B2, similar ghost entries, but evicted from T2.
• T1 and B1 together are referred to as L1, a combined
history of recent single references. Similarly, L2 is
the combination of T2 and B2.
• Note that the ghost lists only contain metadata (keys
for the entries) and not the resource data itself.
L-1
T1
B1
T2
B2
|T1| + |T2| = c
“Ghost caches”
(not in memory)
L-2
 self – tuning
 Low overhead
 Capture both frequency and recency
 Slow.
 complex.
 Can not implemented in the real world.
 Combines the advantages of Adaptive Replacement Cache
(ARC) and CLOCK.
 Like ARC, It uses 4 doubly linked lists. 2 clocks T1 and T2
and 2 simple LRU lists B1 and B2.
 T1 clock stores pages based on ‘recency’ or ‘short term
utility’ whereas T2 stores pages with ‘frequency’’.
 T1 and T2 contain those pages that are in the cache, while
B1 and B2 contain pages that have recently been evicted
from T1 and T2 respectively.
 New pages are inserted in T1 or T2.
 If there is a hit in B1 size of T1 is increased and similarly if
there is a hit in B2 size of T1 is decreased.
 The adaptation rule used has the same principle as that in
ARC.
scan resistant.
self – tuning
Low overhead
Capture both frequency and recency
faster than ARC algorithm.
complex.
Can not implemented in the real world(as hardware).
Computer architecture page replacement algorithms
Computer architecture page replacement algorithms

More Related Content

What's hot

Combined paging and segmentation
Combined paging and segmentationCombined paging and segmentation
Combined paging and segmentation
Tech_MX
 

What's hot (20)

Memory management
Memory managementMemory management
Memory management
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.
 
Run time storage
Run time storageRun time storage
Run time storage
 
Computer architecture virtual memory
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memory
 
OS-Process Management
OS-Process ManagementOS-Process Management
OS-Process Management
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Asynchronous data transfer
Asynchronous data transferAsynchronous data transfer
Asynchronous data transfer
 
Parallel processing
Parallel processingParallel processing
Parallel processing
 
Virtual memory ppt
Virtual memory pptVirtual memory ppt
Virtual memory ppt
 
operating system structure
operating system structureoperating system structure
operating system structure
 
Combined paging and segmentation
Combined paging and segmentationCombined paging and segmentation
Combined paging and segmentation
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Architecture of operating system
Architecture of operating systemArchitecture of operating system
Architecture of operating system
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Multiplication algorithm
Multiplication algorithmMultiplication algorithm
Multiplication algorithm
 
Memory management
Memory managementMemory management
Memory management
 
Swapping | Computer Science
Swapping | Computer ScienceSwapping | Computer Science
Swapping | Computer Science
 
Heap Management
Heap ManagementHeap Management
Heap Management
 
Memory organization in computer architecture
Memory organization in computer architectureMemory organization in computer architecture
Memory organization in computer architecture
 

Similar to Computer architecture page replacement algorithms

Memory management
Memory managementMemory management
Memory management
Rasi123
 
Lecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptxLecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptx
Amanuelmergia
 
08 virtual memory
08 virtual memory08 virtual memory
08 virtual memory
Kamal Singh
 
Ch10 OS
Ch10 OSCh10 OS
Ch10 OS
C.U
 

Similar to Computer architecture page replacement algorithms (20)

Comparision of page replacement algorithms.pptx
Comparision of page replacement algorithms.pptxComparision of page replacement algorithms.pptx
Comparision of page replacement algorithms.pptx
 
Page Replacement
Page ReplacementPage Replacement
Page Replacement
 
Virtual memory and page replacement algorithm
Virtual memory and page replacement algorithmVirtual memory and page replacement algorithm
Virtual memory and page replacement algorithm
 
Memory management
Memory managementMemory management
Memory management
 
Page replacement
Page replacementPage replacement
Page replacement
 
Virtual memory
Virtual memory Virtual memory
Virtual memory
 
Virtual Memory.pdf
Virtual Memory.pdfVirtual Memory.pdf
Virtual Memory.pdf
 
Lecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptxLecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptx
 
4.-CSE-3201_OL1_Paging.pdf
4.-CSE-3201_OL1_Paging.pdf4.-CSE-3201_OL1_Paging.pdf
4.-CSE-3201_OL1_Paging.pdf
 
Virtual Memory Management Part - II.pdf
Virtual Memory Management Part - II.pdfVirtual Memory Management Part - II.pdf
Virtual Memory Management Part - II.pdf
 
08 virtual memory
08 virtual memory08 virtual memory
08 virtual memory
 
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
 
OSCh10
OSCh10OSCh10
OSCh10
 
Ch10 OS
Ch10 OSCh10 OS
Ch10 OS
 
OS_Ch10
OS_Ch10OS_Ch10
OS_Ch10
 
Internet of Things, TYBSC IT, Semester 5, Unit IV
Internet of Things, TYBSC IT, Semester 5, Unit IVInternet of Things, TYBSC IT, Semester 5, Unit IV
Internet of Things, TYBSC IT, Semester 5, Unit IV
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
virtual memory
virtual memoryvirtual memory
virtual memory
 
Page replacement alg
Page replacement algPage replacement alg
Page replacement alg
 
virtual memory Operating system
virtual memory Operating system virtual memory Operating system
virtual memory Operating system
 

More from Mazin Alwaaly

More from Mazin Alwaaly (20)

Pattern recognition voice biometrics
Pattern recognition voice biometricsPattern recognition voice biometrics
Pattern recognition voice biometrics
 
Pattern recognition palm print authentication system
Pattern recognition palm print authentication systemPattern recognition palm print authentication system
Pattern recognition palm print authentication system
 
Pattern recognition on line signature
Pattern recognition on line signaturePattern recognition on line signature
Pattern recognition on line signature
 
Pattern recognition multi biometrics using face and ear
Pattern recognition multi biometrics using face and earPattern recognition multi biometrics using face and ear
Pattern recognition multi biometrics using face and ear
 
Pattern recognition IRIS recognition
Pattern recognition IRIS recognitionPattern recognition IRIS recognition
Pattern recognition IRIS recognition
 
Pattern recognition hand vascular pattern recognition
Pattern recognition hand vascular pattern recognitionPattern recognition hand vascular pattern recognition
Pattern recognition hand vascular pattern recognition
 
Pattern recognition Hand Geometry
Pattern recognition Hand GeometryPattern recognition Hand Geometry
Pattern recognition Hand Geometry
 
Pattern recognition forensic dental identification
Pattern recognition forensic dental identificationPattern recognition forensic dental identification
Pattern recognition forensic dental identification
 
Pattern recognition fingerprints
Pattern recognition fingerprintsPattern recognition fingerprints
Pattern recognition fingerprints
 
Pattern recognition facial recognition
Pattern recognition facial recognitionPattern recognition facial recognition
Pattern recognition facial recognition
 
Pattern recognition ear as a biometric
Pattern recognition ear as a biometricPattern recognition ear as a biometric
Pattern recognition ear as a biometric
 
Pattern recognition 3d face recognition
Pattern recognition 3d face recognitionPattern recognition 3d face recognition
Pattern recognition 3d face recognition
 
Multimedia multimedia over wireless and mobile networks
Multimedia multimedia over wireless and mobile networksMultimedia multimedia over wireless and mobile networks
Multimedia multimedia over wireless and mobile networks
 
Multimedia network services and protocols for multimedia communications
Multimedia network services and protocols for multimedia communicationsMultimedia network services and protocols for multimedia communications
Multimedia network services and protocols for multimedia communications
 
Multimedia content based retrieval in digital libraries
Multimedia content based retrieval in digital librariesMultimedia content based retrieval in digital libraries
Multimedia content based retrieval in digital libraries
 
Multimedia lossy compression algorithms
Multimedia lossy compression algorithmsMultimedia lossy compression algorithms
Multimedia lossy compression algorithms
 
Multimedia lossless compression algorithms
Multimedia lossless compression algorithmsMultimedia lossless compression algorithms
Multimedia lossless compression algorithms
 
Multimedia basic video compression techniques
Multimedia basic video compression techniquesMultimedia basic video compression techniques
Multimedia basic video compression techniques
 
Multimedia image compression standards
Multimedia image compression standardsMultimedia image compression standards
Multimedia image compression standards
 
Multimedia fundamental concepts in video
Multimedia fundamental concepts in videoMultimedia fundamental concepts in video
Multimedia fundamental concepts in video
 

Recently uploaded

Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
Areesha Ahmad
 
Module for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learningModule for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learning
levieagacer
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
PirithiRaju
 
Conjugation, transduction and transformation
Conjugation, transduction and transformationConjugation, transduction and transformation
Conjugation, transduction and transformation
Areesha Ahmad
 
The Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxThe Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptx
seri bangash
 

Recently uploaded (20)

9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
 
pumpkin fruit fly, water melon fruit fly, cucumber fruit fly
pumpkin fruit fly, water melon fruit fly, cucumber fruit flypumpkin fruit fly, water melon fruit fly, cucumber fruit fly
pumpkin fruit fly, water melon fruit fly, cucumber fruit fly
 
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
 
Module for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learningModule for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learning
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
 
Conjugation, transduction and transformation
Conjugation, transduction and transformationConjugation, transduction and transformation
Conjugation, transduction and transformation
 
Zoology 5th semester notes( Sumit_yadav).pdf
Zoology 5th semester notes( Sumit_yadav).pdfZoology 5th semester notes( Sumit_yadav).pdf
Zoology 5th semester notes( Sumit_yadav).pdf
 
Site Acceptance Test .
Site Acceptance Test                    .Site Acceptance Test                    .
Site Acceptance Test .
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)
 
Dubai Call Girls Beauty Face Teen O525547819 Call Girls Dubai Young
Dubai Call Girls Beauty Face Teen O525547819 Call Girls Dubai YoungDubai Call Girls Beauty Face Teen O525547819 Call Girls Dubai Young
Dubai Call Girls Beauty Face Teen O525547819 Call Girls Dubai Young
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
 
300003-World Science Day For Peace And Development.pptx
300003-World Science Day For Peace And Development.pptx300003-World Science Day For Peace And Development.pptx
300003-World Science Day For Peace And Development.pptx
 
Molecular markers- RFLP, RAPD, AFLP, SNP etc.
Molecular markers- RFLP, RAPD, AFLP, SNP etc.Molecular markers- RFLP, RAPD, AFLP, SNP etc.
Molecular markers- RFLP, RAPD, AFLP, SNP etc.
 
FAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical ScienceFAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical Science
 
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate ProfessorThyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
 
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRLKochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
 
Factory Acceptance Test( FAT).pptx .
Factory Acceptance Test( FAT).pptx       .Factory Acceptance Test( FAT).pptx       .
Factory Acceptance Test( FAT).pptx .
 
The Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxThe Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptx
 

Computer architecture page replacement algorithms

  • 1.
  • 2. Plan of Action • What is paging? • Page frame and hit ratio ? • What is page replacement? • Why we need a page replacement algorithm? • What are the algorithms?
  • 3. • In computer operating systems, paging is one of the memory-management schemes by which a computer can store and retrieve data from secondary storage for use in main memory. • In the paging memory-management scheme, the operating system retrieves data from secondary storage in same-size blocks called pages. • Advantage: • is that it allows the physical address space of a process to be non-contiguous. • Before paging came into use, systems had to fit whole programs into storage contiguously, which caused various storage and fragmentation problems.
  • 4. • Page Frame: - The main memory is divided into fixed sized portions called page frame. • The size of page frame is same as the size of page because pages have to reside in page frames. • Hit Ratio: - The ratio of the total number of hit divided by the total CPU access to memory (i.e. hits plus misses) is called hit ratio. • Hit ratio=total number of hits total number f hits + total number of mis
  • 5. A page fault (sometimes called #PF, PF or hard fault) is a type of interrupt, called trap, raised by computer hardware when a running program accesses a memory page that is mapped into the virtual address space, but not actually loaded into main memory. The hardware that detects a page fault is the processor's memory management unit (MMU), and transfers control from the program to the operating system.
  • 6. The operating system must: • Obtain an empty page frame in RAM to use as a container for the data. • Load the requested data into the available page frame. • Update the page table to refer to the new page frame. • Return control to the program. • When all page frames are in use, the operating system must select the page frame to reuse for the page the program now needs., which is its page replacement algorithm.
  • 7. • 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
  • 9. • The main goal of page replacement algorithms is to provide lowest page fault rate.
  • 11. No. of Page Faults Vs No. of Frames
  • 12. • First In First Out. • Optimal Replacement. • Second Chance. • The Clock Algorithm. • Least Recently Used. • Least frquently Used. • Not Recently Used. • ARC(adaptive replacement cache). • CAR(Clock adaptive replacement ).
  • 13. ) • Pages in main memory are kept in a list • First in first out is very easy to implement • The fifo algorithm select the page for replacement that has been in memory the longest time
  • 14. FIFO Example Oldest Hit Hit Hit Newest Fig: FIFO example
  • 15. ▫ FIFO is easy to understand. ▫ It is very easy to implement. • The oldest block in memory may be often used.
  • 16. • The optimal policy selects that page for replacement that will not be needed for the longest time • The OS keeps track of all pages referenced by the program • This algorithm result is fewest number of page faults. • Advantages ▫ Optimal. • Disadvantages ▫ Impossible to implement (need to know the future) but serves as a standard to compare with the other algorithms.
  • 17. OPTIMAL Example Referenced last Hit Hit HitHit Hit Hit Fig: OPTIMAL example
  • 18. • Pages kept in a linked list ▫ Oldest is at the front of the list • Look at the oldest page ▫ If its “referenced bit” is 0...  Select it for replacement ▫ Else  It was used recently; don’t want to replace it  Clear its “referenced bit”  Move it to the end of the list ▫ Repeat • What if every page was used in last clock tick? ▫ Select a page at random
  • 19.
  • 20. • Better performance than FIFO. • Not practical (evicted block may be needed in a short time later).
  • 21. • Variant of FIFO & LRU • Keep frames in circle • On page fault, OS: • Checks reference bit of next frame • If reference bit = 0, replace page, set bit to 1 • If reference bit = 1, set bit to 0, advance pointer to next frame
  • 23.
  • 24. • Easy to implement. • Not practical (evicted block may be needed in a short time later). • Not scan resistant.
  • 25. • The least recently used page replacement algorithm keeps track page uses over a short period of time.
  • 26. LRU Example Recently referenced Hit Hit Hit Hit Hit Hit Fig: LRU example
  • 27. ▫ LRU page replacement algorithm is quiet efficient. ▫ Implementation difficult. This algorithm requires keeping track of what was used when, which is expensive if one wants to make sure the algorithm always discards the least recently used item.
  • 28. Comparison of Clock with FIFO and LRU (1)
  • 30.  The Least-Frequently-Used (LFU) Replacement technique replaces the least-frequently block in use when an eviction must take place.  Software counter associated with each block, initially zero is required in this algorithm.  The operating system checks all the blocks in the cache at each clock interrupt.  The R bit, which is '0' or '1', is added to the ounter for each block. Consequently, the counters are an effort to keep track of the frequency of referencing each block.  When a block must be replaced, the block that has the lowest counter is selected for the replacement.
  • 31. • Frequently used block will stay longer than (fifo)  Older blocks are less likely to be removed , even if they are on longer frequently used because this algorithm never forgets anything.  Newer blocks are more likely to be replaced even if they are frequently used.  Captures only frequency factor.
  • 32. . This algorithm requires that each page have two additional status bits 'R' and 'M' called reference bit and change bit respectively. The reference bit(R) is automatically set to 1 whenever the page is referenced. The change bit (M) is set to 1 whenever the page is modified. These bits are stored in the PMT and are updated on every memory reference.
  • 33. • When a page fault occurs, the memory manager inspects all the pages and divides them into 4 classes based on R and M bits. ▫ Class 1: (0,0) − neither recently used nor modified - the best page to replace. ▫ Class 2: (0,1) − not recently used but modified - the page will need to be written out before replacement. ▫ Class 3: (1,0) − recently used but clean - probably will be used again soon. ▫ Class 4: (1,1) − recently used and modified - probably will be used again, and write out will be needed before replacing it.
  • 34. ( ) • Advantages? ▫ It is easy to understand. ▫ It is efficient to implement. ▫ Much better behavior than FIFO ▫ Frequently used pages are much more likely to stay • Disadvantages? ▫ Behavior sucks near clock cycles
  • 35. • ARC is used (4) linked lists: • T1, for recent cache entries. • T2, for frequent entries, referenced at least twice. • B1, ghost entries recently evicted from the T1 cache, but are still tracked. • B2, similar ghost entries, but evicted from T2. • T1 and B1 together are referred to as L1, a combined history of recent single references. Similarly, L2 is the combination of T2 and B2. • Note that the ghost lists only contain metadata (keys for the entries) and not the resource data itself.
  • 36. L-1 T1 B1 T2 B2 |T1| + |T2| = c “Ghost caches” (not in memory) L-2
  • 37.  self – tuning  Low overhead  Capture both frequency and recency  Slow.  complex.  Can not implemented in the real world.
  • 38.  Combines the advantages of Adaptive Replacement Cache (ARC) and CLOCK.  Like ARC, It uses 4 doubly linked lists. 2 clocks T1 and T2 and 2 simple LRU lists B1 and B2.  T1 clock stores pages based on ‘recency’ or ‘short term utility’ whereas T2 stores pages with ‘frequency’’.  T1 and T2 contain those pages that are in the cache, while B1 and B2 contain pages that have recently been evicted from T1 and T2 respectively.  New pages are inserted in T1 or T2.  If there is a hit in B1 size of T1 is increased and similarly if there is a hit in B2 size of T1 is decreased.  The adaptation rule used has the same principle as that in ARC.
  • 39. scan resistant. self – tuning Low overhead Capture both frequency and recency faster than ARC algorithm. complex. Can not implemented in the real world(as hardware).