Techniques to handle Thrashing


Share post:

Operating system’s spectrum is quite wide with several topics included in it!

From operating system types to its functions to thrashing to demand paging in OS, you will come across several operating system topics.

In this blog post, we are going to discuss another essential operating system topic; thrashing in OS.

Thrash is a term that is used to describe a poor performance of your virtual memory where some pages will be loaded repeatedly that owes to the shortage of your main memory rather than the secondary memory.

In case your computer’s resources are over utilised, the issue of thrashing will occur. It will cause the performance of your computer to collapse or decline.

Hence, there are  several techniques which help in handling thrashing.

Let’s discuss these techniques in detail!

What is a thrash?

In the field of computer science, thrash is defined as a poor performance of your virtual memory or your paging system especially when certain pages will be loaded repeatedly because of insufficient main memory.

Or in other words, this phenomena occurs when your computer’s virtual memory will rapidly exchange a defined data for data in a hard drive, it excludes most of the application level operations. When your main memory will be depleted, many pages will be swapped in or out of the virtual memory.

Based on the algorithm and configuration, the regarded throughput will be degraded by multiple order magnitude. Hence, thrashing generally occurs when your virtual memory resources get overused. This will lead to the constant paging state and page faults with application processing.

The performance of your computer will degrade or collapse. This situation will continue till the user will close some running applications to free up the virtual memory resources.

When you want to know about thrashing, you need to consider two essential concepts:

  • Page fault: As all programs are divided into certain pages. But a page fault will occur when any program attempts to code or access data in an address space which is not currently accessible with the RAM
  • Swapping: When a page fault occurs, your operating system may try to fetch the pages from your secondary memory by swapping it with the other pages in your RAM. This process is known as swapping.

Thrashing occurs when there is swapping or a page fault at a higher rate than usual. Hence, your operating system will take more time in swapping all the pages. This state is basically referred to as the stage of thrashing.

Techniques to handle thrashing

Whenever there is thrashing in the OS, you can make use of certain techniques to handle it. But, for that you need to understand the locality model. It is a set of pages where a process is executed from one locality to the other. As a program involves certain different localities and they may overlap.

So, in this case you can use certain techniques to handle thrashing which are discussed as below:

Working Set Model

This is based on the concept of locality model. The main principle of this model is that we can allocate the frames to accommodate any process in the current locality. When a fault occurs, it moves to some other locality.

Though, if your allocated frames would be less than that of the size of any current locality, the process will thrash. In this model, as with the parameter A, a working set would be defined by pages as A being the most recent reference page. Hence, all activities will be a part of this working set.

The accuracy of any of this set will largely depend on the parameter As value. Though, if A is quite large, the working set will overlap. Though, for small values of A, your locality may not entirely cover.

If D is the demand of frames, i would be the process set size. M will be the number of frames that are available in your memory.

Here d > m which means the demand will exceed the number of frames. Though, d <=m means there will be no thrashing.

Page Fault Thrashing

Another direct approach that helps in handling thrashing is using the page fault thrashing concept. The problem associated with the thrashing concept is the high rate of page fault which controls the rate of page fault.

If any page fault is very high, the process may have too few frames to allocate it. Any low fault rate also indicates a process with too many frames. Though, upper and lower frames will be established on a required page fault.

Though, if a page fault may fall below that of the lower limit, the process will be removed easily. If any page fault exceeds its upper limit, many frames would be allocated towards the process.

The graphical state of any system would be limited to its rectangular region. As the page faults are too high, some of the processes may get suspended.

Other ways to resolve thrashing

To deal with certain page faults, your operating system will either use the local replacement algorithm or global frame algorithm to bring enough frames in your memory.

  • Adjusting the swapping file size: Your swap file would be the portion of a hard disk that is useful in the virtual memory. If your swap file is small it may cause thrashing
  • Increase the size of RAM: If your system may not have enough of the memory space to meet the demands of a running processor, you can add more RAM for reducing thrashing
  • Decrease applications: To run too many applications, your thrashing may pose a heavy demand on the resources of your system. Hence, closing all the unnecessary applications, you can free up your memory space.
Wrapping Up

Operating system is a vast topic with several sub topics like functions of operating system, its types, thrashing, demand paging in operating system among others.

Thrashing in OS is a concept that we have discussed in this blog alongside the techniques to solve this issue.

Happy learning!

Related articles

Is Your Business Tuning Into the Future? Why Online Radio Advertising Is Your Next Big Move

Did you know that alongside the loud and boisterous rise of social media marketing, another digital channel has...

UR full form : in Railway and its Meaning.

UR full form : The abbreviation of ur is  “unreserved”. It is a ticket or reservation that is not...

Moviesming Hollywood Movies and Web Series.

Downloading movies from Moviesming is unlawful. It is a torrent website that gives the means to download an...

From Classroom to Clinic: The Clinical Practicum Experience in BSN Education

The transition from classroom learning to clinical practice is a pivotal phase in the education of nursing students....
error: Content is protected !!