13 Dec 2019

  • December 13, 2019
  • Amitraj
Thrashing in Operating system

If the page fault and swapping happening very frequently at higher rate, then operating system has to spend more time to swap these pages. This state is called thrashing. Because of this, CPU utilization is going to be reduced.

-> Thrashing is also known as disk thrashing.



Code vidyalay explains Thrashing

Thrashing happens when too many computer processes compete for inadequate memory resources. Thrashing can occur due to several factors, with the most prominent reason being insufficient RAM or memory leakage. In a computer, some applications have higher priorities than others and this can also attribute to thrashing when there is a lack of memory resources. Thrashing can cause slowdown of the system performance since data transfer has to be between the hard drive and physical memory. One of the early signs of thrashing is when an application stops responding while the disk drive light blinks on and off. The operating system often warns users of low virtual memory when thrashing is occurring.


-> A temporary solution for thrashing is to eliminate one or more running applications. One of the recommended ways to eliminate thrashing is to add more memory to main memory. Another way of resolving the issue of thrashing is by adjusting the size of the swap file.




Effect of Thrashing

Whenever thrashing starts, operating system tries to apply either Global page replacement Algorithm or Local page replacement algorithm.

Global Page Replacement


Since global page replacement can access to bring any page, it tries to bring more pages whenever thrashing found. But what actually will happen is, due to this, no process gets enough frames and by result thrashing will be increase more and more. So global page replacement algorithm is not suitable when thrashing happens.


Local Page Replacement

Unlike global page replacement algorithm, local page replacement will select pages which only belongs to that process. So there is a chance to reduce the thrashing. But it is proven that there are many disadvantages if we use local page replacement. So local page replacement is just alternative than global page replacement in thrashing scenario.





Techniques to Handle Thrashing
We already seen Local replacement is better than Global replacement to avoid thrashing. But it also has disadvantages and not suggestable. Some more techniques are


1. Working Set Model

This model is based on locality. What locality is saying, the page used recently can be used again and also the pages which are nearby this page will also be used. Working set means set of pages in the most recent D time. The page which completed its D amount of time in working set automatically dropped from it. So accuracy of working set depends on D we have chosen. This working set model avoid thrashing while keeping the degree of multiprogramming as high as possible.




Page Fault Frequency





-> It is some direct approach than working set model. When thrashing occurring we know that it has few number of frames. And if it is not thrashing that means it has too many frames. Based on this property we assign an upper and lower bound for the desired page fault rate. According to page fault rate we allocate or remove pages. If the page fault rate become less than the lower limit, frames can be removed from the process. 

-> Similarly, if the page fault rate become more than the upper limit, more number of frames can be allocated to the process. And if no frames available due to high page fault rate, we will just suspend the processes and will restart them again when frames available.

Translate

Popular Posts