1Definition
Thrashing is a severe operating system degradation condition that occurs when a process lacks sufficient physical frames to support its active pages, causing the system to spend more time servicing continuous page faults than executing actual instructions. Techniques to prevent thrashing include the Working Set Model and the Page Fault Frequency (PFF) scheme.
2Simple Explanation
Imagine a student taking 10 hard exams on the same day. The student's desk (RAM) can only fit 2 open textbooks (Frames). Every 5 seconds, the student puts away a textbook to open another textbook (Page Fault). The student spends 99% of their time picking up and putting down books, and 1% of their time actually writing answers.
This state of chaotic unproductive thrashing is Thrashing. CPU utilization plunges to near 0% because all processes are queued up waiting for the hard drive swap disk!
3Real-Life Example / Analogy
An Overwhelmed Waiter: A single waiter assigned to 50 dining tables simultaneously. The waiter spends all their time running back and forth between the kitchen door and tables without delivering any food, resulting in complete service breakdown.
4Diagram / Visual Representation
5Working / How It Works
- The Thrashing Death Spiral:
- OS notices low CPU utilization.
- Long-term scheduler increases Degree of Multiprogramming by introducing new processes into RAM.
- New processes take physical frames away from existing running processes.
- Existing processes fault for their evicted pages -> Queue up at disk I/O swap queue.
- CPU becomes idle waiting for disk I/O -> OS misinterprets idle CPU and introduces even more processes!
- CPU utilization crashes to zero as system thrashes continuously.
- Handling Thrashing:
- Working Set Model: Measures a process's Locality (the set of pages actively used during a time window ). If total demand , suspend a process to avoid thrashing.
- Page Fault Frequency (PFF): Establishes upper and lower bounds on page fault rates. If fault rate > Upper Limit, allocate process another frame. If fault rate < Lower Limit, revoke a frame.
6Types / Components / Characteristics
- Locality Model: Programs execute in local clusters (functions, loops, arrays). A process moves from one locality to another throughout execution.
- Working Set Window (): The fixed number of recent page references used to calculate the active Working Set Size ().
7Solved Examples / Problems
Problem: A system has 100 available physical frames. Three active processes have Working Set Sizes: , , . Calculate total demand and determine if thrashing will occur. Solution:
- Total Memory Demand .
- Available Physical Frames = 100.
- Compare: .
- Conclusion: Total demand exceeds physical frames! Thrashing WILL occur. The OS must swap out one process (e.g., suspend Process 3) to free frames and restore stability.
8Advantages, Disadvantages & Applications
- Working Set Advantages: Prevents thrashing while maximizing the Degree of Multiprogramming.
- Disadvantages: Tracking recent reference windows in real-time adds runtime overhead.
9Important Points to Remember
- Thrashing occurs when an OS spends more time servicing page faults than executing instructions.
- If total working set demand , thrashing is guaranteed.
10Test Your Understanding
- MCQ: What is the primary operational cause of system Thrashing?
- A) Setting the Round Robin time quantum to a very large value.
- B) Allocating fewer frames to a process than required to support its active locality of reference.
- C) Executing pure demand paging on 64-bit hardware.
- D) Using a Microkernel architecture.
Show answer
B. - Conceptual Question: Describe the Working Set Model and explain how the parameter is chosen.
- Application Question: Explain how the Page Fault Frequency (PFF) method dynamically prevents thrashing using upper and lower threshold bounds.
