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.
What a learner can do afterwards
- 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
1 · Read
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.
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.
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.
Faults fetch, policies pick victims, thrashing crawls, and the optimum needs the future.
2 · Watch
Take it off screen
Where it sits
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.