Thrashing in Operating Systems: Meaning, Causes, Occurrence, and Prevention
Thrashing is a severe virtual memory performance failure in which the operating system spends most of its time moving pages between disk and RAM instead of running instructions.2 In practical terms, a process is said to be thrashing when it spends more time handling page faults than performing useful computation. This usually appears in demand-paged systems when the combined memory demand of active processes exceeds the available physical frames, causing repeated eviction and reloading of pages.2
Thrashing is tightly connected to locality of reference and the working set of a process.2 If a process does not have enough frames to hold its current locality, the next memory references are likely to fault again and again.2 When this happens across multiple processes, CPU utilization drops, disk I/O rises, and throughput can collapse rather than improve as system load increases.2
A useful formal view is the working-set criterion:
where is the working-set size of process , and is the total frame demand of all active processes.2 If , where is the number of available physical frames, at least one process will be under-provisioned and thrashing becomes likely.2
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩ ↩2 ↩3 ↩4
-
Thrashing - GeeksforGeeks - Explains locality, working set model, and page-fault frequency control. ↩ ↩2 ↩3 ↩4 ↩5
-
What is Thrashing? Why Does it Occur? | Lenovo US - Describes practical symptoms and the role of excessive swapping. ↩
-
Peter J. Denning -- Working Set Publications - Primary historical source on working sets, locality, and thrashing prevention. ↩ ↩2 ↩3 ↩4
-
THRASHING - Peter J. Denning - Classic overview of throughput collapse under excessive load and paging contention. ↩
Thrashing in Operating Systems
Key Diagnostic Insight
Low CPU utilization does not always mean the system needs more jobs. In a thrashing state, CPU utilization may fall because processes are blocked waiting for pages to be fetched from disk.
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩
What exactly is thrashing?
Thrashing is not merely “having many page faults.” It is the unstable condition in which the page-fault rate becomes so high that useful execution is overshadowed by paging overhead.2 The classic symptom is that the system becomes sluggish while storage activity remains intense.2 Historically, Peter Denning described it as a collapse of throughput caused by excessive contention for memory, especially when system load increases beyond a critical point.
This behavior is most common in systems using demand paging, because pages are brought into RAM only when referenced.2 Demand paging is efficient when a process's active pages fit in memory, but it becomes pathological when the active memory footprint of several processes no longer fits.2
Important indicators include:3
- Very high page-fault frequency
- Heavy disk or swap activity
- Poor response time
- Falling CPU utilization despite a high workload
- Throughput collapse as more processes are added
A concise distinction is shown below.
| Condition | Memory behavior | CPU behavior | I/O behavior | Outcome |
|---|---|---|---|---|
| Normal paging | Occasional page faults | Mostly productive execution | Moderate | Stable performance |
| High memory pressure | Faults increase | More waiting | Increased paging I/O | Slower system |
| Thrashing | Continuous page replacement | Little useful execution | Paging dominates | Throughput collapse |
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩ ↩2 ↩3 ↩4 ↩5 ↩6
-
THRASHING - Peter J. Denning - Classic overview of throughput collapse under excessive load and paging contention. ↩ ↩2 ↩3
-
What is Thrashing? Why Does it Occur? | Lenovo US - Describes practical symptoms and the role of excessive swapping. ↩ ↩2 ↩3
-
Peter J. Denning -- Working Set Publications - Primary historical source on working sets, locality, and thrashing prevention. ↩
-
Thrashing - GeeksforGeeks - Explains locality, working set model, and page-fault frequency control. ↩ ↩2 ↩3
How Thrashing Develops
Load Increases
Stage 1The operating system admits more processes or the workload grows, increasing total memory demand.2"
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩
-
THRASHING - Peter J. Denning - Classic overview of throughput collapse under excessive load and paging contention. ↩
Frames Per Process Shrink
Stage 2Each process receives too few frames to hold its active locality, so memory references increasingly miss in RAM.2"
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩
-
Thrashing - GeeksforGeeks - Explains locality, working set model, and page-fault frequency control. ↩
Page Fault Rate Surges
Stage 3Repeated references trigger frequent faults, forcing constant transfers between disk and memory.2"
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩
-
What is Thrashing? Why Does it Occur? | Lenovo US - Describes practical symptoms and the role of excessive swapping. ↩
Paging Disk Becomes Bottleneck
Stage 4The system spends more time servicing faults than running instructions, so throughput drops sharply."
Footnotes
-
THRASHING - Peter J. Denning - Classic overview of throughput collapse under excessive load and paging contention. ↩
Feedback Loop
Stage 5If the scheduler misreads low CPU utilization as spare capacity, it may admit more processes, making the problem worse."
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩
When does thrashing occur?
Thrashing occurs when the active memory demand of running processes exceeds available physical memory frames.3 More specifically, it arises when a process's current locality cannot be retained in memory long enough for reuse.2 In a multiprogrammed system, this often happens when the degree of multiprogramming becomes too high.2
Three common trigger conditions are especially important:
- Insufficient frames for a process's current locality: if the pages needed in the near future are repeatedly evicted, the process faults on them again almost immediately.2
- Too many concurrently active processes: the sum of working sets exceeds RAM, so the system cannot satisfy all active localities simultaneously.2
- Aggressive global replacement effects: under global replacement, one memory-hungry process can steal frames from others, spreading instability system-wide.
The working-set test is the standard conceptual rule:
Here, is the recent working set of process , and is the total number of frames.2
Another useful control model is page-fault frequency (PFF). If the observed fault rate for a process rises above an acceptable upper bound, the process needs more frames; if no free frames exist, the system should reduce the active workload rather than continue admitting processes.2
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩ ↩2 ↩3 ↩4
-
Thrashing - GeeksforGeeks - Explains locality, working set model, and page-fault frequency control. ↩ ↩2 ↩3 ↩4 ↩5 ↩6
-
Peter J. Denning -- Working Set Publications - Primary historical source on working sets, locality, and thrashing prevention. ↩ ↩2 ↩3 ↩4
-
THRASHING - Peter J. Denning - Classic overview of throughput collapse under excessive load and paging contention. ↩
-
Page Replacement Algorithms (UNC slides) - Describes page-fault frequency as a control method for allocating frames. ↩
Step-by-Step Diagnosis of Thrashing
- 1Step 1
Look for sharp slowdowns, poor interactivity, elevated swap or paging traffic, and a large rise in page faults.2
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩
-
What is Thrashing? Why Does it Occur? | Lenovo US - Describes practical symptoms and the role of excessive swapping. ↩
-
- 2Step 2
If utilization is low while disk activity is high, the system may be waiting for page transfers rather than lacking runnable work.
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩
-
- 3Step 3
A persistently high fault rate is a central indicator that active pages are not remaining resident long enough.3
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩
-
Thrashing - GeeksforGeeks - Explains locality, working set model, and page-fault frequency control. ↩
-
Page Replacement Algorithms (UNC slides) - Describes page-fault frequency as a control method for allocating frames. ↩
-
- 4Step 4
Compare total recent working-set demand against available frames. If total demand exceeds RAM, the system is in a danger zone for thrashing.2
Footnotes
-
Thrashing - GeeksforGeeks - Explains locality, working set model, and page-fault frequency control. ↩
-
Peter J. Denning -- Working Set Publications - Primary historical source on working sets, locality, and thrashing prevention. ↩
-
- 5Step 5
Determine whether global replacement, over-admission of processes, or poor frame allocation is amplifying the problem.2
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩
-
Thrashing - GeeksforGeeks - Explains locality, working set model, and page-fault frequency control. ↩
-
- 6Step 6
Increase frames, suspend some processes, or reduce the degree of multiprogramming so that active working sets fit in memory.3
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩
-
Thrashing - GeeksforGeeks - Explains locality, working set model, and page-fault frequency control. ↩
-
Peter J. Denning -- Working Set Publications - Primary historical source on working sets, locality, and thrashing prevention. ↩
-
Core Prevention Principle
Thrashing is avoided when the system keeps the active working sets of currently running processes resident in memory.3
Footnotes
-
Thrashing - GeeksforGeeks - Explains locality, working set model, and page-fault frequency control. ↩
-
Peter J. Denning -- Working Set Publications - Primary historical source on working sets, locality, and thrashing prevention. ↩
-
THRASHING - Peter J. Denning - Classic overview of throughput collapse under excessive load and paging contention. ↩
Why does thrashing become self-reinforcing?
Thrashing is dangerous because it forms a feedback loop. When memory pressure grows, page faults increase; when page faults increase, the CPU waits more often for I/O; when CPU utilization falls, a simplistic scheduler may incorrectly assume the system can handle more work. Admitting more processes then reduces frames per process even further, which drives the page-fault rate still higher.2
This is why Denning's analysis is historically important: throughput does not always rise smoothly with load. Beyond a critical point, it can collapse suddenly. The paging device or backing store becomes the bottleneck, and the system enters a state sometimes described as “paging to death.”
A mathematical intuition is:
As grows large due to repeated page faults, the fraction of time spent on useful execution shrinks rapidly.2
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩ ↩2 ↩3
-
THRASHING - Peter J. Denning - Classic overview of throughput collapse under excessive load and paging contention. ↩ ↩2 ↩3 ↩4
Conceptual Effect of Memory Pressure on Performance
Illustrative trend based on the classic thrashing model: throughput rises with load up to a critical point, then falls as paging dominates.
Footnotes
-
THRASHING - Peter J. Denning - Classic overview of throughput collapse under excessive load and paging contention. ↩
How can thrashing be avoided?
Avoiding thrashing is fundamentally a problem of load control and frame allocation.2 The operating system must ensure that active processes have enough frames to cover their present locality.2 The principal strategies are below.
1. Use the working-set model
The working-set model estimates the set of pages each process has used within a recent window of references, often denoted by .2 The system keeps enough frames for that set, and if the sum of all working sets exceeds memory, it suspends or swaps out some processes rather than letting all of them run poorly.3
2. Use page-fault frequency control
PFF monitors the fault rate directly.2 If a process faults too often, the OS gives it more frames; if its fault rate is very low, some frames may be reclaimed.2 If free frames are unavailable, the correct response is often to reduce the number of active processes.2
3. Reduce the degree of multiprogramming
This is one of the most direct solutions.2 By suspending some processes, the system increases the memory available to the remaining ones, allowing their localities to fit and stabilizing execution.2
4. Prefer local replacement in unstable conditions
Local replacement prevents one process from stealing frames from others. While not a complete cure, it can contain the spread of thrashing.
5. Increase physical memory
Adding RAM increases the number of available frames and lowers the likelihood that active working sets exceed capacity.2 This is a practical remedy, though not the only one.
6. Design workload and admission policies carefully
Systems should avoid blindly increasing concurrency based only on CPU utilization. Better policies use memory pressure, fault rates, and working-set estimates before admitting more tasks.2
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8
-
Thrashing - GeeksforGeeks - Explains locality, working set model, and page-fault frequency control. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9
-
Peter J. Denning -- Working Set Publications - Primary historical source on working sets, locality, and thrashing prevention. ↩ ↩2 ↩3
-
THRASHING - Peter J. Denning - Classic overview of throughput collapse under excessive load and paging contention. ↩ ↩2
-
Page Replacement Algorithms (UNC slides) - Describes page-fault frequency as a control method for allocating frames. ↩ ↩2 ↩3
-
What is Thrashing? Why Does it Occur? | Lenovo US - Describes practical symptoms and the role of excessive swapping. ↩
The OS estimates the pages referenced in the last references for each process. If total demand exceeds available frames , some processes should be suspended so active working sets fit in memory.2
Footnotes
-
Thrashing - GeeksforGeeks - Explains locality, working set model, and page-fault frequency control. ↩
-
Peter J. Denning -- Working Set Publications - Primary historical source on working sets, locality, and thrashing prevention. ↩
Common Questions and Edge Cases
Practical summary
Thrashing is a memory-management failure state in which the system spends excessive time paging and too little time executing useful instructions.2 It occurs when active working sets do not fit in physical memory, commonly because the degree of multiprogramming is too high or frame allocation is insufficient.3 The most effective prevention methods are to monitor working sets or page-fault frequency, reduce active process load when necessary, and ensure that each active process has enough frames for its current locality.3
For exam and interview purposes, the essential rule is:
And the essential remedy is:
Footnotes
-
Operating Systems: Virtual Memory - University course notes defining thrashing, its causes, and scheduler interaction. ↩ ↩2
-
THRASHING - Peter J. Denning - Classic overview of throughput collapse under excessive load and paging contention. ↩
-
Thrashing - GeeksforGeeks - Explains locality, working set model, and page-fault frequency control. ↩ ↩2
-
Peter J. Denning -- Working Set Publications - Primary historical source on working sets, locality, and thrashing prevention. ↩ ↩2
-
Page Replacement Algorithms (UNC slides) - Describes page-fault frequency as a control method for allocating frames. ↩
Knowledge Check
Which statement best defines thrashing in an operating system?
Explore Related Topics
Process in Operating Systems and the Contrast Between Interprocess Communication Models
A process is the active execution of a program with its own state, resources, and PCB, and operating systems use it for scheduling, protection, and cooperation via interprocess communication (IPC); the two primary IPC models—shared memory and message passing—differ in data movement, synchronization, kernel involvement, and suitability for local versus distributed use.
- PCB stores a process’s state, registers, scheduling info, and resource data, enabling context switches.
- Standard process lifecycle: new → ready → running → waiting/blocked → terminated.
- IPC is required for cooperating processes because each has an isolated address space.
- Shared memory offers high performance for large local data but demands explicit synchronization.
- Message passing provides easier, safer communication and works well across machines, at the cost of higher kernel overhead.
tRPC Crash Course: End-to-End Type Safe APIs
tRPC is a TypeScript‑only RPC framework that lets frontend code call backend functions with full, compile‑time type safety, no code generation, and minimal runtime overhead.
- API endpoints are defined as simple TypeScript procedures (queries, mutations, subscriptions) grouped in routers.
- The builder pattern lets you chain input validation, middleware, and the handler, creating reusable base procedures (e.g., protectedProcedure).
- Context provides shared data (session, DB) to every procedure, while middleware can enforce auth, logging, or other cross‑cutting concerns.
- Tight integration with Next.js (App or Pages Router) enables zero‑config type sharing and React Query hooks for caching and SSR.
- Features like
httpBatchLinkbatch multiple calls into one request, but tRPC is best for internal TypeScript services and isn’t suited for public non‑TS clients.
The Banker's Algorithm: Deadlock Avoidance in Operating Systems
The Banker's Algorithm is a deadlock‑avoidance method that keeps a system in a safe state by checking each resource request against the maximum declared needs of processes.
- Maintains Available, Max, Allocation, and Need matrices, where .
- The Safety Algorithm uses vectors Work and Finish to find an execution order; if all processes finish, the state is safe.
- The Resource‑Request Algorithm simulates allocation, runs the safety check, and commits only if the resulting state remains safe.
- Time complexity of the safety check is .
- In practice the algorithm is rarely used because processes must predeclare maximum needs and the algorithm’s overhead is high.