← 💾 Virtual Memory
Subtopic 5 of 5

6.5Thrashing, working set and frame allocation

The idea

Thrashing is when processes spend more time paging than computing. The working-set model gives each process the frames it needs.

Think of it like this: A student with too many open books on a small desk: they spend all the time swapping books and read nothing.

Why it exists

It explains the collapse in CPU utilisation as multiprogramming rises, and what the OS should do about it.

How it works

  1. Each process needs a set of pages (its working set) in memory to make progress.
  2. If total demand exceeds the frames, everyone faults constantly.
  3. CPU utilisation drops, the scheduler admits more processes, and things get worse.
  4. Cure: reduce the degree of multiprogramming or use page-fault-frequency control.

Worked example: Working-set sizes 40, 30, 50 and 100 frames in total

Demand is 120 > 100 frames, so thrashing: suspend at least one process, which brings demand down to a level that fits.

Now play with it

  • →Drag the slider beyond 8 processes and watch the utilisation fall.
  • →Think about why adding a process at the bottom of the curve is the wrong reaction.
memory is full: thrashing startsdegree of multiprogrammingCPU utilisation %

4 processes → CPU utilisation about 74%

The curve is schematic, not measured. The real lesson: when the OS sees low CPU use it adds more processes, which makes it worse past the peak. The cure is to lower the degree of multiprogramming or use a working-set policy.

Check yourself

The OS observes low CPU utilisation and high paging. The best response is to

Remember: Thrashing = constant faulting. Remedy: fewer processes, working-set or PFF control.
Exam notes (the dense version)

Thrashing: processes do not have enough frames for their working pages, so they fault constantly and the CPU sits idle, which tempts the scheduler to admit more processes and makes it worse. The working-set model keeps the pages used in the last Δ references; the sum of working-set sizes must not exceed the number of frames. Cures: lower the degree of multiprogramming, page-fault-frequency control. Allocation: equal, proportional to size, or priority-based; local replacement (own frames) limits interference, global replacement can steal frames from others.

Previous year questions: Virtual Memory (9)

PYQs are grouped by topic, so this is the full set for Virtual Memory; try the ones that match this subtopic. Open all 9 on the topic page.