# Page replacement

Week 7 · Memory · Operating Systems
The page also has an interactive playground: https://alfonsocampodonico.com/classes/operating-systems/page-replacement?lang=en
Code: https://github.com/AlfonsoCampodonico/os-playground/tree/main/src/sim (`gh repo clone AlfonsoCampodonico/os-playground`)

> FIFO, LRU, OPT and Clock on the same trace: which one has the fewest page faults?

When physical memory is full, the operating system must choose a page to evict. Compare policies on the same trace and look for Belady’s anomaly.

**OSTEP:** chapters 21–22, and the playground reproduces its `paging-policy.py` homework simulator, seed for seed.

The playground above keeps its whole setup in the URL, so a link to this page reproduces the exact example. Change the inputs, step through it, and share the link.
