Thrashing- Causes of Thrashing and How to Prevent Thrashing in OS

Thrashing in OS
Write For Us Technology
Write For Us Technology
Our purpose with Write For Us Technology is to contribute to the world of readers (seekers) and help sharing information on technology to resolve related misconceptions and, to ignite a chain of thoughts in their beautiful minds.

Table of Contents

With continuous multitasking, you may feel drained and tired. You would certainly feel like your system is about to shut down, right? This is exactly how our operating system feels when it overloads and comes close to shutting down. The technical term for this is thrashing in OS.

One would think that our operating system would be the pro of multitasking but, that is certainly not the case all the time.

Here in this blog, we will unravel the virtues of the multiprogramming operating system and vividly discuss thrashing in OS

Thrashing

To put it in simple terms for non-technical people out there we can define thrashing as buffering for the memory system of your computer. 

Thrashing basically occurs because your CPU is no longer capable of storing new data in its main memory. 

This leads to lagging of the entire computer system and you will find that the same page is loading time and again. This phenomenon is also termed paging

Depending on the number of algorithms and configurations that you were trying to run, the multitude of thrashing that occurs in your computer system will reflect the same. 

If this continues for an extended period it will eventually lead to your computer crashing. It is clear that thrashing occurs due to the overuse of the virtual memory of the CPU. 

This lagging can continue for an extended period until the user decides to close all the running programs and eventually the whole computer system. 

Now that you might have a brief understanding of the phenomenon of thrashing in the computer system, let us discuss it in detail. First, we need to clear the following two terms:

  • Page fault: Since all the programs are divided into several pages, a page fault occurs when a program is trying to access data from a certain page that has not been added to the system memory yet. This means that the address code for the page currently doesn’t exist in the memory. 
  • Swapping: This occurs right after page fault. The system will now try to access the page from the secondary memory and simultaneously replace it with another page stored in the RAM. This process is termed swapping. 

So now in the process of thrashing, your operating system is trying to run both page fault and swapping processes at the same time. This will lead to a continuation of the same procedure recurrently. Hence, contributing to the lag in the CPU. 

The functioning of the CPU will be drastically reduced, immediately slowing it down to finally stopping altogether. 

To understand this better, imagine that the operating system is running a program with fewer frames, it will eventually lead to the utilization of more and more pages until the system finally succumbs to thrashing. 

Now that we have discussed thrashing at length, let us try to understand some of the causes of thrashing. 

Causes of thrashing in OS

  • It might be difficult to comprehend but one of the causes of thrashing is minimal utilization of the CPU. Since the CPU is being utilized in a regulated amount the operation system will try to deploy multiple programs at the same time, providing fewer frames to each at a given time hence leading to thrashing. 
  • The amount of utilization of the CPU, whether less or extremely high, both situations lead to the thrashing of the operating system ultimately. 
  • The utilization of the CPU might also increase with an increase in the amount of multiprogramming. 
  • With an increase in the level of multiprogramming, we observe a noticeable downfall in the performance of the CPU. 

We can conclude from these causes that in a situation of thrashing we must try and reduce the level of multiprogramming of the CPU. 

While the CPU experiences thrashing, the operating system tries to employ the following algorithms:

  • Global page replacement

This algorithm has access to any page globally hence, at times of thrashing the global page algorithm tries to bring in various other pages that can be found in the instance. The main notable drawback of this algorithm is that no single process gets enough frame to completely follow through with the procedure. Since there are not enough frames available the operating system will certainly start experiencing thrashing. So in conclusion this algorithm is not as useful as it seems. 

  • Local page replacement

Unlike the global page replacement algorithm, the local page replacement algorithm will only try to access pages from the same program. This to a certain level is definitely effective in order to reduce thrashing. 

But similarly, like the global page replacement algorithm, this has also received its fair share of criticism. Hence this is only a slightly better alternative for the global page replacement algorithm when it comes to thrashing. 

It is evident that the phenomenon of thrashing has some severe impact on the hard drive of the CPU hence, it is reasonable to create solutions to avoid this altogether. 

How to avoid thrashing? 

  • Adjust the size of the swap file

If the size of the swap file accessed by the operating system is not configured properly. It will eventually lead to thrashing. 

  • Increase RAM space

As we have already discussed, the space in the RAM highly affects the probability of thrashing the operating system. It is best if you try to manage the space in your RAM and increase it proportionately. This will allow the running and processing of several programs at the same time. 

  • Reduce the number of background applications

If there are way too many programs or applications running on your computer at the same time, it will certainly lead to the thrashing of the operating system. Hence, it is best to keep the background applications count at a minimum. 

  • Replace programs

Finally, you can also try to switch the programs that consume relatively more space with the alternate versions that are less space-consuming. 

Conclusion

Even though our operating system is a technical device that has been programmed to perform several tasks at the same time, it certainly cannot escape from buffering or thrashing at times. 

In this blog, you will find a few details about the multiprogramming operating system along with detailed information about the phenomenon of thrashing in the OS.

Share This Post -
Write For Us Technology
Write For Us Technology
Our purpose with Write For Us Technology is to contribute to the world of readers (seekers) and help sharing information on technology to resolve related misconceptions and, to ignite a chain of thoughts in their beautiful minds.
Related Posts

4 thoughts on “Thrashing- Causes of Thrashing and How to Prevent Thrashing in OS”

  1. Ԍood day! І simply wish to give you a huge thumbѕ up for your great information yoս hаve got right here on this post.
    I will be coming back to your blog for moгe soon.

  2. Nice post. I learn something totally new and challenging on blogs I stumbleupon on a daily basis. It will always be interesting to read content from other writers and use something from other sites.

  3. Wonderful paintings! This is the kind of info that are supposed to be shared around the web. Shame on Google for not positioning this publish higher! Come on over and consult with my web site . Thank you =)

Leave a Comment

Your email address will not be published. Required fields are marked *