the aging algorithm
True LRU is too costly because it would touch hardware on every memory access. The aging algorithm is a clever cheat that approximates it using just one bit per page that the hardware already maintains: the reference bit, set to 1 whenever a page is touched and reset by the OS. Think of it like a fading memory of recent activity — each page carries a small history, and as time passes that history quietly decays, so pages active recently look 'fresh' and long-idle pages fade toward forgotten.
Here is the mechanism. The OS gives each page a small register of bits, say 8 bits, all starting at 0. At regular intervals (a timer tick) it shifts every page's register one bit to the right and slides that page's current reference bit into the leftmost (high-order) position; then it clears the reference bit for the next interval. Over time a page touched in recent intervals accumulates 1s near the top, giving it a large value, while a page idle for many intervals fills with 0s, giving it a small value. To replace, the OS evicts the page with the smallest register value — that is the one with the least recent activity, the aging approximation of least-recently-used.
Why it matters: aging captures LRU's spirit using only a periodic shift over cheap reference bits, no per-access hardware needed. It is more informative than a single reference bit because it remembers several intervals of history, not just 'touched or not since last check.' Its honest limits: time is quantized by the tick, so within one interval it cannot distinguish order of accesses, and ties (equal register values) must be broken by some other rule. It is an approximation, not exact LRU — but a good and practical one.
Using 8-bit registers, a page touched this interval and the previous one might read 11000000 (large), while a page idle for the last several intervals reads 00000010 (small). At a fault the OS evicts the small one. Each tick it shifts right and drops in the latest reference bit.
Shift the history right each tick; the smallest value is the oldest, least-recent page.
Aging approximates LRU but cannot order accesses within a single timer interval, and equal register values need a tie-breaker. It is more precise than one reference bit, yet still not true LRU.