/    /  OS – Techniques to handle Thrashing 

Techniques to handle Thrashing 

Thrashing is the state in which the CPU performs lesser “productive” work and more “swapping”.

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

To avoid it there are primarily two known techniques, global page replacement, and local page replacement, but as both of them has their demerits and is not very effective at stopping thrashing there are few more techniques:

 

 

  • Working Set Model

 

Working set refers to a set of pages in a recent T time. The pages that have completed their T amount of time in the working set are automatically dropped from it. 

So the accuracy depends on the T we choose.

 

It is efficient in avoiding thrashing and in keeping the degree of multiprogramming as high as possible.

 

Let us assume that ‘m’ is the number of frames and ‘D’ is total demand, then:

  • D>m implies that the total demand exceeds the number of frames, hence thrashing will occur.
  • D<=m implies that total demand is less than or equal to the total number of frames, then thrashing will be avoided.

 

  1. Page faulty frequency

We know that in thrashing there are fewer frames, and in the opposite situation, if it is not thrashing it implies there is an excess of frames, based on this data we assign an upper and lower bound for the desired page fault rate.

According to the page fault rate we allocate and remove pages.

If the page fault rate is more than the upper bound several pages are allocated to the system, and if the number of pages is lower than the lower bound then pages are removed, the suspended process is restarted later on.

 

Reference

Techniques to handle Thrashing