/    /  OS – Thrashing in Operating System

Thrashing in Operating System

 

What is thrashing?

A state in which the CPU performs lesser “productive” work and more “swapping” is known as thrashing. 

It occurs when there are too many pages in the memory and each page refers to another one.

The CPU is busy swapping and hence its utilization falls. 

 

What are the causes of thrashing?

The process scheduling mechanism tries to load many processes in the system at a time and hence the degree of multiprogramming is increased. In this scenario, there are far more processes than the number of frames available. 

The memory soon fills up and the process starts spending a lot of time for the required pages to be swapped in, causing the utilization of the CPU to fall low, as every process has to wait for pages.

 

Effect of thrashing?

When the operating system encounters a situation of thrashing then it tries to apply the following algorithms:

  1. Global page replacement
  2. Local page replacement

 

Global page replacement

Whenever there is thrashing, the global page replacement algorithm tries to bring more pages.

Though, this is not a suitable algorithm as in this no process can get enough frames causing more thrashing.

 

Local page replacement

This algorithm may help in the reduction of thrashing as it brings pages that belongs to the process. 

But there are many other disadvantages of local page replacement and hence it is only used as an alternative for global page replacement.

 

Thrashing in Operating System Reference