TLTLBeast
← Back to timeline

Page Replacement Policies

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

operating-systemsvirtual-memorypage-replacementcaching
Handwritten notes on memory pressure, AMAT, and page replacement policies
Day scribble — eviction, AMAT, miss types, and replacement algos

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 memory
  • T_d — cost of accessing disk

Miss types

MissWhy
CompulsoryCache starts empty
CapacityCache ran out of space
ConflictLimits 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.

PolicyIdea
FIFOFirst in, first out — arguably worse than optimal
RandomLuck of the draw — theoretically can match optimal
LRULeast recently used — frequency + recency; less likely to kick out a page you just needed
MRUMost recently used — bad; ignores locality

Next up: analyze complex workloads and chart how each policy does.

Get in Touch

Questions, feedback, or just want to talk systems? Send a message and it'll land in my inbox.

If I send you a message back, it might end up in your spam folder — just please check that.