SWAPON DISKFRAME 0FRAME 1FRAME 2FRAME 3FRAME 4FRAME 5ABCCPUUSEFUL WORK-t-3t-2t-1nowFAULT RATE-
Back: swap on the disk and RAM, six page framesMiddle and front: programs A, B, C, the CPU and its meters, A's last four referencesTiles: pages moving between swap and RAM (a page fault each)Swap and six RAM frames at the back; programs A, B and C and the CPU in the middle; A's last four references and the fault rate in front. A and B fill the six frames once and then always hit. When C joins, nine pages chase six frames: each fault evicts the page needed next, every reference faults and the CPU idles. Suspending C ends it. The 100 nanoseconds for RAM and 10 milliseconds for a disk are the round numbers OSTEP uses. Solid-state drives are much faster than 10 ms, but still far slower than RAM, so the collapse still happens, only less steeply.

Working sets

  1. RAM is split into page frames, here just six, and every running program keeps its pages in them. A page that is not in RAM waits in swap on the disk. Touching it is a page fault: the kernel must fetch it first.

When they fit

Thrashing

Getting out

What happens

;; step 1/10 · shared
page frame   one page-sized slot of RAM (4 KiB on most PCs)
swap         disk space for pages that do not fit in RAM
page fault   the page is not in RAM: the kernel reads it
             from swap, maybe evicting another page first

this example: 6 frames, global LRU replacement
RAM access   about 100 ns     disk access   about 10 ms (OSTEP)

The example is tiny on purpose: 6 frames, three programs of three pages, one reference per turn and exact LRU. Real machines have millions of frames and approximate LRU (for example with the clock algorithm), but the cliff is the same: once total demand passes RAM, faults take over. Useful work is worked out as 100 ns / (100 ns + fault rate x 10 ms): one disk serves the faults one at a time, and while every program waits for it the CPU has nothing to run. At a 100% fault rate that is about 0.001%.