4.1.16 · D1Computer Architecture (Deep)

Foundations — Page replacement — FIFO, LRU, Clock, Optimal

2,288 words10 min readBack to topic

This page assumes you have seen nothing. Before we can read a single row of the parent note's tables, we must earn every word and symbol it uses. We build them in an order where each one leans on the one before it.

See the parent: Page replacement — FIFO, LRU, Clock, Optimal.


1. Memory as a row of boxes

Start with the most physical picture possible: memory is a long row of numbered boxes, and each box holds one number.

Figure — Page replacement — FIFO, LRU, Clock, Optimal

Why the topic needs it: every idea below is about where data lives (fast box vs slow box) and how we name those places. Without the box picture, "page", "frame", and "address" are just words. See Virtual Memory & Paging for the full machinery.


2. RAM vs Disk — fast shelf, slow warehouse

There are two kinds of storage in our story, and their speed gap is the whole reason the topic exists.

Why the topic needs it: because the warehouse trip is so expensive, the entire goal is to avoid it. Every policy in the parent note is a strategy to keep the right things on the desk.


3. Pages and Frames — cutting memory into equal chunks

We never move memory one box at a time; that would be wasteful. We move it in fixed-size blocks.

Figure — Page replacement — FIFO, LRU, Clock, Optimal

Why the topic needs it: the parent note's tables show frames filling up with page numbers. "3 frames" means "3 parking spots". When all spots are full and a new page arrives — that is exactly when replacement happens.


4. The symbol — how many frames

Read as: "there are three parking spots." That's the whole meaning. No calculus, no hidden trick — it is a small whole number.


5. The reference string — the program's shopping list

A running program does not touch pages randomly; it asks for them one after another in a definite order. We write that order down.

Figure — Page replacement — FIFO, LRU, Clock, Optimal

Why the topic needs it: every worked example in the parent walks this string left to right, one column per reference. It is the raw input to all four policies.


6. Hit vs Fault — the only two outcomes

For each page on the list, exactly one of two things happens. There is no third case — this cleanliness is what makes counting possible.

Why the topic needs it: the whole subject is minimizing page faults. Each fault is one expensive warehouse trip. See TLB & Address Translation for how the CPU checks "is present?" quickly.


7. Evict / Victim — making room

This one word — which victim? — is the entire subject. FIFO, LRU, Clock, Optimal are four different answers to that single question.


8. The set and the symbol — what's in RAM now

The parent note tracks "the pages currently in frames" using a set. Let's earn that symbol.


9. Set operations and — swapping the victim

When we evict victim and bring in new page , the parent writes:

Let's decode it piece by piece — nothing here is scary.


10. The fault rate — turning a count into a fraction


11. The reference bit — one bit of memory-of-usage

The Clock policy needs one last tiny symbol.


How these foundations feed the topic

Memory as numbered boxes

RAM fast vs Disk slow

Pages and Frames

F = number of frames

Reference string

Hit vs Page Fault

Evict and Victim

Set S and size of S

Set ops remove and union

Fault rate fraction

Replacement Policy question

FIFO LRU Clock Optimal

Reference bit R

Every arrow means "you need the left idea before the right one makes sense." Notice all roads lead to the bottom box — the four policies — which is what the parent note is really about.


Equipment checklist

Cover the right side and answer aloud. If any one stumps you, re-read its section above before opening the parent.

What is an address, in the boxes picture?
The number of a memory box; the data is what's inside it.
Roughly how much slower is a disk access than a RAM access?
About (one hundred thousand) times slower.
What is the difference between a page and a frame?
A page is a chunk of the program's data; a frame is the fixed-size slot in real RAM that holds one page.
What does stand for?
The number of frames — how many pages fit in RAM at once.
What is a reference string?
The time-ordered sequence of page numbers the program touches.
Name the only two outcomes for any page reference.
A hit (page already in a frame) or a page fault (page not in a frame).
What does mean, and what does it imply?
" is a member of set " — meaning is in RAM, so it's a hit.
What does imply?
is not in RAM — a page fault.
Read in plain words.
" becomes: remove victim , then add new page " — one eviction.
What is a victim?
The page chosen by the policy to be evicted to make room for a new one.
Write the fault-rate formula and say why we divide.
; we divide to make the count comparable across programs (a fraction between 0 and 1).
What is the reference bit and who sets it?
A one-bit flag per frame set to by hardware whenever the page is used; means untouched since last check.