CAP366 · Unit 7: Memory management
Allocation of frames, thrashing and the working-set model
15 practice questions · in the ETE syllabus
Key points
- Equal and proportional frame allocation
- Thrashing: more time paging than executing
- Working set = distinct pages in last Δ references
- If total demand exceeds frames, suspend a process
Every process needs a minimum number of frames, set by the instruction set architecture. Allocation schemes: equal (m frames among n processes, m/n each) and proportional (in proportion to process size, a_i = s_i / S x m). Example: 62 frames shared by processes of 10 and 127 pages give about 4 and 57 frames. Replacement can be global (a victim from any process) or local (a victim from the faulting process only).
Thrashing occurs when a process spends more time paging than executing because it lacks enough frames. CPU utilisation drops, so the scheduler may admit more processes, which makes it worse.
The working-set model uses a window of the most recent Δ page references; the set of distinct pages in it is the working set, an approximation of the process's current locality. If the total demand D = sum of working-set sizes exceeds the number of frames m, thrashing is likely and a process should be suspended. If Δ is too small it misses part of the locality; if too large it spans several localities and over-estimates the need.
An alternative is page-fault frequency (PFF): increase frames when the fault rate exceeds an upper bound, reduce them below a lower bound.
Exam trap: low CPU utilisation caused by thrashing is cured by lowering, not raising, the degree of multiprogramming.
Try two questions
Which Linux kernel thread frees pages in the background when free memory falls below a threshold?
- kswapd
- init
- kthreadd
- ksoftirqd
Show the answer
A. kswapd wakes when free memory drops below a low watermark and reclaims pages until enough are free. If that is not fast enough, an allocating process does direct reclaim itself.
Why not B: init is the first user process, not a reclaim thread.
Why not C: kthreadd starts other kernel threads.
Why not D: ksoftirqd runs deferred interrupt work.
The working-set sizes of four processes are 20, 35, 15 and 40 frames, and the system has 100 frames. What is the conclusion?
- The total demand of 90 is below 100 frames, so all four processes fit
- The total demand of 110 is high, so the system should admit more processes
- The total demand of 110 exceeds 100 frames, so a process should be suspended
- The total demand of 100 fills memory exactly, so nothing needs to change
Show the answer
C. The total working set demand is 110, which exceeds the 100 available frames, so thrashing is likely and a process should be suspended.
Why not A: The sum is 110, not 90, so the demand exceeds the frames.
Why not B: Admitting more processes would deepen the shortage of frames.
Why not D: The sum is 110, not 100, so memory is over-committed.