Download - CSE Four Fiddy One
![Page 1: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/1.jpg)
CSE Four Fiddy One
Section 7
Kurtis Heimerl (kheimerl@)
Aaron Kimball (ak@)
![Page 2: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/2.jpg)
What you’ve luckily skipped:
• Project 3 - Your job: Replacement Algorithms– Given:
• random– You need to write:
• FIFO• LRU Clock• One of your choice
– A few possibilities:» True LRU (e.g. via storing full timestamp)» Variations on LRU Clock (enhanced second-chance, etc)» LFU/MFU» Your own!
– You can write more than 3 if your experiment focuses on replacement algorithms.
So we’ll go over some aspects of this you may have missed.
![Page 3: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/3.jpg)
Paging Algorithms(Thanks wikipedia!)
• FIFO (First in/first out)– Replace the oldest page with the one being paged in
• Second-Chance (Modified FIFO)– FIFO, but skip referenced pages
• Random– Duh
• NFU (Not Frequently Used)– Replace the page used the least number of times
• NRU (Not Recently Used)– Replace a page not used since last clock cycle
• LRU (Least Recently Used)– Replace the least recently used page
• LRU Clock (Modified LRU)– Replace the least recently used page, with a hard limit on the max time since
used• Clairvoyant
– Replace the page that’s going to be needed farthest in the future.
![Page 4: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/4.jpg)
FIFO
• First in/First out
• Advantages?
• Problems?
![Page 5: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/5.jpg)
FIFO
• First in/First out
• Advantages?– Little Bookkeeping
• Problems?– Efficiency
• Why?
![Page 6: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/6.jpg)
FIFO
• First in/First out
• Advantages?– Little Bookkeeping
• Problems?– Efficiency
• Why?
– Belady's anomaly• What is it?
![Page 7: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/7.jpg)
Belady's anomaly
Belady's anomaly states that it is possible to have more page faults when increasing the number of page frames while using FIFO method of frame management. Laszlo Belady demonstrated this in 1970. Previously, it was believed that an increase in the number of page frames would always provide the same number or fewer page faults.
![Page 8: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/8.jpg)
Example
Page Requests321032432104
![Page 9: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/9.jpg)
Example (Page Faults in Red)
Page Requests – 3 frames
Frame 1
Frame 2
Frame 3
3 2 1 0 3 2 4 3 2 1 0 4
3 3 3 0 0 0 4 4 4 4 4 4
2 2 2 3 3 3 3 3 1 1 1
1 1 1 2 2 2 2 2 0 0
![Page 10: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/10.jpg)
Example (Page Faults in Red)
• Page Requests – 4 frames
• Frame 1
• Frame 2
• Frame 3
• Frame 4
3 2 1 0 3 2 4 3 2 1 0 4
3 3 3 3 3 3 4 4 4 4 0 0
2 2 2 2 2 2 3 3 3 3 4
1 1 1 1 1 1 2 2 2 2
0 0 0 0 0 0 1 1 1
![Page 11: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/11.jpg)
Second-Chance FIFO
• Simply add a referenced bit to FIFO pages.
• Advantages?
• Disadvantages?
![Page 12: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/12.jpg)
Second-Chance FIFO
• Simply add a referenced bit to FIFO pages.
• Advantages?– Obvious improvement over FIFO– Allows commonly used pages to stay in queue
• Disadvantages?– Still suffers from Belady's anomaly
![Page 13: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/13.jpg)
Random
• Randomly Select a page to be replaced
• Advantages?
• Disadvantages?
![Page 14: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/14.jpg)
Random
• Randomly Select a page to be replaced
• Advantages?– Usually better than FIFO– Better than LRU in some degenerate cases
(looping)– Easy to implement
• Disadvantages?– Less than efficient in most common cases
![Page 15: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/15.jpg)
NFU (Not Frequently Used)
• Remove the page used the least number of total times
• Advantages?
• Disadvantages?
![Page 16: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/16.jpg)
NFU (Not Frequently Used)
• Remove the page used the least number of total times
• Advantages? – Frequently used pages stay longer than FIFO
• Disadvantages?– Older pages are less likely to be removed,
even if they are no longer frequently used– Newer pages are more likely to be replaced
even if they are frequently used
![Page 17: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/17.jpg)
NRU (Not Recently Used)
• Remove the page used the least often since the last clock cycle
• Advantages?
• Disadvantages?
![Page 18: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/18.jpg)
NRU (Not Recently Used)
• Remove the page used the least often since the last clock cycle
• Advantages? – Much better behavior than FIFO or NFU– Frequently used pages are much more likely
to stay
• Disadvantages?– Behavior sucks near clock cycles
![Page 19: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/19.jpg)
LRU (Least Recently Used)
• Remove the page not used for the longest period of time
• Advantages?
• Disadvantages?
![Page 20: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/20.jpg)
LRU (Least Recently Used)
• Remove the page not used for the longest period of time
• Advantages? – Great efficiency behavior
• Disadvantages?– Implementation difficult. How do you keep
track of the time each page was last used?
![Page 21: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/21.jpg)
LRU Clock (Modified LRU)
• Remove the page with the longest time since it’s use, with a hard cap on that time.
• Advantages?
• Disadvantages?
![Page 22: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/22.jpg)
LRU Clock (Modified LRU)
• Remove the page with the longest time since it’s use, with a hard cap on that time.
• Advantages? – Very close approximation of LRU– Cap on hardware resources needed
• Disadvantages?– Still not optimal
![Page 23: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/23.jpg)
Clairvoyant
• Remove the page that will be needed farthest in the future
• Advantages?
• Disadvantages?
![Page 24: CSE Four Fiddy One](https://reader035.vdocument.in/reader035/viewer/2022070418/56815922550346895dc64a5b/html5/thumbnails/24.jpg)
Clairvoyant
• Remove the page that will be needed farthest in the future
• Advantages? – Optimal
• Disadvantages?– Impossible to implement