CSE 451
Operating Systems
L18 - Demand Paging, Page Replacement
Slides by: Tom Anderson
Rohan Kadekodi
Demand Paging (Before)
Page B
Demand Paging
instruction
Demand Paging (After)
Locating a Page on Disk
Allocating a Page Frame
PA
PA
VA
VA’
VA -> PA
PgTable (Proc 1)
PgTable (Proc 2)
TLB
Has page been modified/recently used?
Tracking page modifications (Before)
|
|
|
|
|
|
|
|
|
|
|
Tracking page modifications (After)
|
|
|
|
|
|
|
|
|
|
|
Modified/Use Bits are (often) Virtual
=> May need to copy some unmodified bytes back to disk
Use Bits are Fuzzy
back to disk?
single page not used for the longest”
Emulating a Modified Bit
Emulating a Recently Used Bit
Models for Application File I/O
Advantages to Memory-mapped Files
Implementing Memory-Mapped Files
From Memory-Mapped Files to Demand-Paged Virtual Memory
Cache Replacement Policy
A Simple Policy
FIFO in Action
Worst case for FIFO is if program strides through memory that is larger
than the cache
MIN, LRU, LFU
miss
LRU/MIN for Sequential Scan
Belady’s Anomaly
Question
page will do
Clock Algorithm: Estimating LRU
Second Chance List
if (page is dirty) {
flush to disk, mark page as clean, unused
} else if (page is used) { mark page as unused
} else {
mark as invalid; put at end of “second chance” list
if page is referenced, pull off “second chance” list, mark
page as valid
}
Recap