Thrashing and Frame Allocation in Operating Systems: Concepts, Worked Examples and Exam Traps
Learn why frame shortages cause sustained page faults, how allocation and replacement scope differ, and how working-set and PFF calculations guide recovery.
KnowledgeGate Team
Exam prep & CS education

Adding more active processes can make a computer do less useful work. With too few resident frames, page faults repeat, processes wait for paging I/O, and CPU utilisation falls. Thrashing is distinct from an ordinary fault burst. Frame allocation and recovery can be analysed together.
What thrashing means, and why the CPU can become idle
A frame is a physical-memory slot that holds one page. A process's resident set is its pages currently in frames. A page fault occurs when a referenced page is not resident. The degree of multiprogramming is the number of active processes.
Page faults are normal in demand paging. Thrashing is the sustained condition in which the system spends much of its time servicing faults instead of executing useful instructions.
The damaging feedback loop is:
A process has too few frames for its current locality.
Its page-fault rate rises, so it repeatedly blocks for paging I/O.
CPU utilisation falls because fewer processes are ready.
A naive controller admits another process to raise utilisation.
The new process increases frame pressure and fault rates.
Low CPU utilisation alone does not prove thrashing. Ordinary I/O or a light workload can also leave the CPU idle. Look for sustained high page-fault activity. Demand Paging in Operating Systems follows a legal but absent page through the fault handler; thrashing begins when active localities repeatedly evict one another.
Frame allocation and replacement scope are separate decisions
Suppose 10 frames are available for three processes whose address spaces contain 20, 30, and 50 pages.
Equal allocation gives each process 3 frames. The policy must decide who receives the remaining frame, or keep it free.
Proportional allocation uses the total size of 100 pages:
10 x 20/100 = 2,10 x 30/100 = 3, and10 x 50/100 = 5frames.Priority allocation can favour an important process, but it cannot remove a system-wide shortage.
Allocation sets a process's frame count. Replacement scope sets where a victim comes from. Local replacement uses only the process's own frames. It isolates processes but can trap a starved process in a tiny resident set. Global replacement can take another process's frame. It adapts faster but can raise that process's fault rate.
Proportional allocation uses address-space size. A working set contains the pages needed in the current locality. A large process can have a small working set, while a small process can touch many pages.
Worked example: detect the frame shortage first
Physical memory has 12 frames. The OS reserves 2, leaving m = 12 - 2 = 10 frames for user processes. Use a working-set window of the most recent eight references:
P1: 1,2,3,4,1,2,3,4, soWSS1 = {1,2,3,4}and|WSS1| = 4.P2: 5,6,5,7,5,6,5,7, soWSS2 = {5,6,7}and|WSS2| = 3.P3: 8,9,10,11,12,8,9,10, soWSS3 = {8,9,10,11,12}and|WSS3| = 5.
Total demand is D = 4 + 3 + 5 = 12. Since D = 12 > m = 10, the localities need 12 - 10 = 2 more frames. Redistributing 10 frames cannot fit all three working sets.
Proportional allocation gives P1 2 frames although it needs 4. P2 gets 3 and needs 3; P3 gets 5 and needs 5. Suspending P2 removes its three-page working set. Demand becomes 4 + 5 = 9, and 9 <= 10. Allocate 4 frames to P1 and 5 to P3, leaving 10 - 9 = 1 free. This is an example choice, not a universal rule about which process to suspend.

Why two extra frames change P1's fault behaviour
LRU victim selection depends on recency; the full LRU Page Replacement walkthrough traces those decisions. With the cyclic string 1,2,3,4,1,2,3,4, frame capacity becomes the decisive variable.
Reference | 1 | 2 | 3 | 4 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|---|---|---|
Two-frame state |
|
|
|
|
|
|
|
|
Outcome | F | F | F | F | F | F | F | F |
That is 8 faults in 8 references because four active pages cannot fit in two frames.
With four frames, the first states are [1,-,-,-] F, [1,2,-,-] F, [1,2,3,-] F, and [1,2,3,4] F. References 1, 2, 3, and 4 then hit with no state change. This cold start has 4 compulsory faults and 4 hits. Another cycle would be all hits unless the locality changed.
This trace identifies a resident-set shortage. It does not prove that LRU always prevents thrashing. FIFO, LRU, and other replacement rules all perform poorly when an active locality cannot fit in its allocated frames.

Detect and control thrashing with working sets and PFF
Choose a window Delta, find each process's distinct pages, sum their counts as D, and compare D with frames m. A small Delta can miss part of a locality; a large one can blend old and current localities. A problem should supply the window or enough information to infer it.
Page-fault frequency (PFF) offers another check. Suppose the problem defines a high threshold of 40% and a low threshold of 10% for a 20-reference interval:
Process | Fault calculation | PFF | Decision |
|---|---|---|---|
P1 |
| 55% | Above high threshold |
P2 |
| 15% | Between thresholds |
P3 |
| 45% | Above high threshold |
These problem-supplied thresholds are not universal constants. P1 and P3 need help, but no process is below the low threshold, so there is no obvious donor. Reduce the degree of multiprogramming instead of merely reshuffling frames.
When a safe donor exists, give a high-fault process more frames and reclaim from a process below the low threshold. Otherwise, suspend or swap out a process until enough frames are available. Load control, working-set allocation, and PFF control are mechanisms, not guaranteed cures.
How exam questions test thrashing and allocation
Typical questions ask you to calculate equal or proportional shares, compute working-set sizes and test D > m, or interpret a CPU-utilisation and page-fault graph before choosing a control action.
Use this order:
Find usable frames after the OS reservation.
Calculate the stated allocation.
Calculate active demand or page-fault rates.
Compare demand with supply, or each rate with its threshold.
Choose the action only after the comparison.
Keep units and denominators visible, such as 11 faults / 20 references = 55%. That makes an answer auditable.
Traps, the short version, and the next study step
Remember the common traps:
One page fault is not thrashing.
Increasing multiprogramming can worsen a frame shortage.
Global replacement redistributes frames; it does not create them.
A better replacement algorithm cannot make 12 active pages fit into 10 frames.
Process size is not current working-set size.
Giving one process more frames can hurt another under global replacement.
Thrashing is sustained paging caused when active-locality demand outruns available frames. Diagnose it with a working-set or PFF calculation. Reallocate frames when possible, or reduce the degree of multiprogramming when total demand is too high.
If you are building Operating Systems from first principles, continue with Zero to Hero. If you are revising OS alongside other core subjects for technical interviews, use the Computer Science course. The CS Fundamentals collection connects this topic to the wider subject.
Keep learning
Thrashing and Frame Allocation MCQs: 12 Solved Questions
Test your understanding of thrashing, frame allocation, working sets, page faults, and recovery through 12 MCQs with step-by-step explanations.
Deadlock in Operating Systems: Four Conditions and Worked Resource-Allocation Graphs
Learn why a cycle proves deadlock only for single-instance resource types, then trace a three-process deadlock and a multiple-instance escape sequence.
File Management in Operating Systems: Allocation, Directories and Worked Examples
Connect a filename to its inode, open-file state, and physical blocks. Then compare allocation methods and solve one complete block-allocation example.
File Systems and Allocation MCQs: 12 solved questions with explanations
File systems and allocation MCQs for GATE, state PSC and PSU papers: contiguous, linked and indexed allocation, Unix i-node sizing, directories, disk layout.





