Page Replacement Policies
Memory pressure means eviction — main memory as a cache, AMAT, miss types, and Belady / FIFO / random / LRU / MRU.

Memory pressure
Lots of free memory → just pull a page off the free list and assign it to the faulting page.
Low memory → memory pressure forces the OS to page out actively-unused pages to make room. That's eviction, driven by page replacement policies.
Memory as a cache
Main memory holds a subset of virtual pages — it's a cache for them. Goal: minimize misses, maximize hits.
Average memory access time:
AMAT = (P_hit × T_m) + (P_miss × T_d)
T_m— cost of accessing memoryT_d— cost of accessing disk
Miss types
| Miss | Why |
|---|---|
| Compulsory | Cache starts empty |
| Capacity | Cache ran out of space |
| Conflict | Limits on where an item can sit (e.g. two items hash to the same spot) |
Replacement policies
Optimal (Belady's): replace the page accessed furthest in the future. Perfect — and impossible to know for sure. Use it as a baseline; look at the past, can't know the future.
| Policy | Idea |
|---|---|
| FIFO | First in, first out — arguably worse than optimal |
| Random | Luck of the draw — theoretically can match optimal |
| LRU | Least recently used — frequency + recency; less likely to kick out a page you just needed |
| MRU | Most recently used — bad; ignores locality |
Next up: analyze complex workloads and chart how each policy does.