---
title: "Paging, Page Faults and Replacement Policies"
description: "When a page is not resident the hardware raises a fault and the kernel fetches it, possibly evicting another. Which page leaves is a policy question, and a bad answer produces thrashing, where the mac"
canonical: https://lightmysky.com/learn/computing/paging-page-faults-and-replacement-policies-mt_nEEuGL89Ze
source: https://lightmysky.com/learn/computing/paging-page-faults-and-replacement-policies-mt_nEEuGL89Ze.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Paging, Page Faults and Replacement Policies

When a page is not resident the hardware raises a fault and the kernel fetches it, possibly evicting another. Which page leaves is a policy question, and a bad answer produces thrashing, where the machine spends its time moving pages instead of running code.

Subject: Computing · Area: Computer Systems · Ages 20 to 21
Page: https://lightmysky.com/learn/computing/paging-page-faults-and-replacement-policies-mt_nEEuGL89Ze

## Ready when they can

- Count the faults a reference string causes under least recently used and under first in first out
- Explain what thrashing looks like from outside the machine
- Say why the optimal policy can be described but not implemented

## Lesson: Faults, victims, and thrashing

When your page is not resident, the hardware raises a fault and the kernel fetches it. If no frame is free, some other page is evicted first. The evicted page is called the victim.

**Example.** Three frames hold pages, and references run 1, 2, 3, 1, 4. The first three load with faults, 1 hits, and 4 faults while evicting a victim. Least recently used and first in first out both fault 4 times here.

Thrashing is what failure looks like from outside. The disk works constantly, the machine creeps, and little real code runs. The system spends its time moving pages instead of running programs.

**Tip.** The optimal policy evicts the page used farthest in the future. It can be described in one line but never implemented, because the kernel cannot see the future.

**Recap.** Faults fetch, policies pick victims, thrashing crawls, and the optimum needs the future.

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [The Memory Hierarchy and Why Caching Works](https://lightmysky.com/learn/computing/the-memory-hierarchy-and-why-caching-works-mt_0f5ArFPlxP)
- [Virtual Memory and Address Translation](https://lightmysky.com/learn/computing/virtual-memory-and-address-translation-mt_B-PiAyderj)

## Opens up

- [File Systems: Names, Blocks and Metadata](https://lightmysky.com/learn/computing/file-systems-names-blocks-and-metadata-mt_jN4u3idvF3)
- [Serving a Model: Batching, the Key-Value Cache and Quantisation](https://lightmysky.com/learn/computing/serving-a-model-batching-the-key-value-cache-and-quantisation-mt_Nv1-WLGIO4)
