The state when the system spends a lot of time in page fault, but the actual execution of process is negligible is called thrashing.
In the initial stage when we increase the degree of multi-programming then CPU utilization is very high up to lemda(). Lemda is the stage at which the memory is full and swapping ( IN/OUT) is just going to start.
At point lemda, if we increase degree of multi-programming then CPU utilization is sharply falling down. This situation is Thrashing. Look at the following diagram for detail.
In simple words we can also say that, at a certain point of CPU utilization, the continuously of page fault is called Thrashing.
When Thrashing Happened?
As SWAP IN and SWAP OUT (page replacement) is done by OS not by CPU. Continuously of page swap in/out cause thrashing because there is no CPU execution at the time of swapping. OS also enable the programs to access main memory, Hard disk, I/O device and Hard Disk also.
Let explain with example
Let suppose memory is full with 4 pages and CPU demand for page 5 .OS replace page 5 with page 1. After replacing as the CPU go for execution the P5 and just before execution of P5, CPU demand for page 1 as OS brings the page 1 by replacing page 2 and try to execute page 1 CPU again demand for page 2 and so on.
So here, OS again and again performing the swap in/out operations and nothing is going to execute. It is thrashing situation.
Conclusion: when swap out page is demanded by CPU before to execute any other page in main memory then system performance decease dramatically. It may be happened due to dependency of ready to execute page and swap out page.
Problems of Thrashing
Decrease the performance of system.
How to handle with Thrashing
- Locality Model
- Handle through decreasing the page fault