Trashing_in_Operating_System
Trashing_in_Operating_System
Introduction
In an operating system, processes need memory (RAM) to run efficiently. When there are too many
processes and not enough memory, the system keeps moving pages in and out of memory very frequently.
This situation where the CPU spends more time swapping pages instead of doing actual work is called
Trashing. Trashing badly affects the system performance and slows down all processes.
Thus, trashing happens when the system is busy with paging activity instead of process execution.
What is Trashing?
- Trashing occurs when a process spends more time paging than executing.
- It usually happens when there are too many active processes in memory and not enough frames available
for them.
- The system keeps loading pages and replacing pages continuously, resulting in very few instructions being
- It leads to high CPU utilization for paging activities but low useful work.
Cause of Trashing
- All processes compete for limited memory, causing frequent page faults.
2. Insufficient Frames:
- Each process does not get enough frames to hold its working set.
- Bad replacement algorithms may remove useful pages, causing more page faults.
- OS may add more processes thinking CPU is free, but actually, CPU is busy with paging.
Trashing in Operating System
4. This swapping repeats again and again because the process cannot keep its working set in memory.
5. CPU spends more time handling page faults and less time executing instructions.
6. As a result, system slows down heavily, even though CPU utilization may look high.
Example of Trashing
Thus:
- A gets 7 frames
- B gets 7 frames
- C gets 6 frames
None of the processes have enough frames. They keep replacing and swapping pages constantly.
Result:
This is trashing.
Detection of Trashing
5. Load Control: