Translation Lookaside Buffer (TLB): Small HW cache on MMU for recently used pages (typically 16-64 pages, so 64-256KB memory)
TLB Management:
Page Fault: Accessing an evicted (invalid) PTE
Page Daemon: A kernel thread to proactively evict pages when memory is close to full
Temporal Locality: Locations referenced recently are likely to be reference again (e.g. for loop index i)
Spatial Locality: Locations close by are likely to be referenced soon (e.g. sequential array access)
Placement Policy: Where to put a page (469: placement impacts performance more when lots of memory is available)
Fetch Policy: When to swap a frame into memory
Replacement Policy: Which page to evict? (evaluated by counting number of page faults over a reference string)
Belady’s Optimal: Look at future reference string, evict the least-used page (not practical, a upper-bound yardstick to compare with other algorithms)
Random Replacement: Evict a random page (a lower-bound for evaluation)
FIFO (First in First out): Evict the oldest page (temporal locality) (bad: an old page can be used very frequently)
LRU (Least Recently Used): Evict the page hasn’t been used for the longest time in the past. (bad when sequential access to a large array > physical memory)
Second Chance Algo: FIFO but evict a page with ref bit 0 (and prefer clean pages)
⭐ Clock Algo: Circular list of pages, clock hand pointing at the next oldest
LFU (Least Frequently Used): Count number of accesses in the past (pages heavily used but no longer relevant may stick around)
Simplified 2Q: Two queues, one A1 FIFO (hold pages used once) and one Am LRU