LightMySky
En anglais

Paging, Page Faults and Replacement Policies

Accessing a valid nonresident page can cause a recoverable fault. The OS supplies the page and may reclaim a frame. FIFO and LRU choose different victims. Repeated faults and page transfers can leave little time for execution when actively used pages do not fit in available RAM.

No account needed. Progress saves in this browser.

What a learner can do afterwards

  • Count LRU and FIFO faults from a stated reference string, frame count and initial contents
  • Explain how frequent faults and page transfers can limit progress during thrashing
  • Explain optimal replacement for a known trace and why past references alone cannot guarantee optimal online choices

1 · Read

Address translation can fault when a valid page is not resident in RAM. The OS may load its contents or supply a zero-filled page, then retry. Invalid accesses and permission violations need different handling. In our replacement model, each frame holds one page. An absent-page reference counts as a fault; if all frames are full, evict a resident victim before loading.

valid page absentfault enters OSOS supplies pageretry access

Least recently used, or LRU, evicts the resident page whose last reference was earliest. Every access, including a hit, refreshes recency. With two empty frames and references 4, 5, 4, 6, 4, the first two loads fault. The next 4 hits. Loading 6 evicts 5; the final 4 hits. Total: three faults.

4: fault5: fault4: hit6: fault, evict 54: hit

First in first out, or FIFO, evicts the earliest-loaded resident page. A hit does not change arrival order. With two empty frames and references 4, 5, 4, 6, 4, the first two loads fault and the next 4 hits. Loading 6 evicts 4. The final 4 faults and evicts 5. Total: four faults.

4: fault5: fault4: hit6: fault, evict 44: fault, evict 5

Thrashing means repeated faults and page transfers consume much of the time needed for useful execution. It often occurs when actively used pages do not fit in available RAM. Progress slows while paging activity is high. A busy storage device alone does not prove thrashing; other work also reads and writes storage.

needed page absenttransfer pagebrief executionanother needed page absent

For a known finite trace, optimal replacement evicts the resident page used farthest in the future. A page never used again is a suitable victim. An offline simulator can inspect the remaining trace. A running kernel generally lacks that future information; logging past references cannot guarantee the best victim for every possible continuation.

inspect next referenceabsent: count faultif full, evict victimload requested page
Process references in order. Count loads into empty frames as faults too.

LRU does not have strictly fewer faults than FIFO on every trace. With two empty frames and references A, B, A, both load A and B with faults, then hit on A. Both have two faults. One tie disproves a claim of always fewer faults.

LRU refreshes recency on hits; FIFO keeps arrival order. Count from stated initial frames. Thrashing limits progress; optimal replacement uses future references.

Lesson, worked questions and flashcards about page faults and replacement policies were written for this dataset.

2 · Watch

En anglais

Take it off screen

Print a worksheetA4 with an answer key page for grown-ups. No screen, no internet.

Where it sits

Then practise

8 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.

Spotted a problem on this page? Tell us
Paging, Page Faults and Replacement Policies · Computing, ages 20 to 21 · LightMySky