Overview

Page Replacement Policies dictate how the operating system manages physical RAM under memory pressure. When physical frame capacity is reached during Demand Paging, the kernel must select an existing physical frame to evict to disk. This module covers page eviction algorithms, physical frame allocation across competing processes, program locality, and strategies to prevent catastrophic Thrashing.


Module Notes

Note LinkDescriptionKey Concepts
Page Replacement AlgorithmsAnalysis of eviction policies under memory pressure, hardware requirements, and algorithmic trade-offs.Belady’s Optimal (MIN), FIFO, Belady’s Anomaly, LRU, Clock (Second-Chance)
Thrashing & Frame Allocation PoliciesProgram locality models, synchronous vs. asynchronous page eviction, multi-process frame allocation, Working Set theory, and Thrashing mitigations.Temporal/Spatial Locality, Global vs. Local Allocation, Working Set Model, OOM Killer

Page Eviction & Allocation Lifecycle

When physical RAM fills up, the memory subsystem balances page eviction and process frame distribution:

flowchart TD
    Fault["Page Fault Triggered (Demand Paging)"] --> CheckRAM{"Physical RAM Full?"}
    CheckRAM -->|"No"| Alloc["Allocate Free Frame"]
    CheckRAM -->|"Yes"| Policy["Run Page Replacement Algorithm"]
    
    Policy --> Evict["Evict Victim Page<br/>(Write to Swap if Dirty)"]
    Evict --> Alloc
    
    subgraph SystemPressure ["System Memory Pressure Metrics"]
        Allocation["Frame Allocation (Global vs Local)"]
        Locality["Locality Tracking (Working Set Size)"]
        Overload{"Sum of WSS > RAM?"}
    end
    
    Alloc --> SystemPressure
    Overload -->|"Yes"| Thrashing["System Thrashing<br/>(Disk I/O Collapses CPU Utilization)"]
    Overload -->|"No"| Stable["Stable Execution"]
    
    Thrashing --> Mitigate["Mitigate: Swap Process / OOM Killer"]

Algorithm Summary Comparison

AlgorithmBasis for EvictionHardware Support RequiredBelady’s Anomaly Subject?Practical Utility
Optimal (MIN)Farthest access in futureRequires future prescienceNoOffline Benchmark Only
FIFOOldest page brought into RAMNoneYesPoor
LRULeast recently accessed pageHardware Timestamps / StackNoHigh Cost / Theoretical
ClockApproximates LRU via circular scanPTE Reference Bit ()NoStandard Production Implementation