causes of thrashing in os
gate study material for cse operating system tutorial notes

Thrashing in Operating System | Cause of Thrashing in OS

Causes of Thrashing in OS

The causes of thrashing in os are explained here in this tutorial. In this thrashing tutorial, we will learn about Thrashing and its causes and how to overcome Thrashing in os.

Dear readers after reading this tutorial you will able to answer the questions related to thrashing concept is operating system.

Frequently Asked Questions

After reading these causes of thrashing tutorial, computer science graduate will be able answer to the following questions.

  •  What is thrashing in Operating System ?
  •  What are the causes of thrashing in os?
  •  How to overcome Thrashing?
  •  What is the Working set model?
  • How does the Working set model work
  • What is the degree of multi-programming?
  • What is the Locality of reference?

So let’s start with the introduction of Thrashing.

What is Thrashing in OS?

  • Thrashing occurs when a Process spends more time in paging or Swapping activities rather than its execution.
  • In Thrashing, the CPU is so much busy in swapping that it cannot respond to the user program as much as it required.

Causes of Thrashing in Operating System

  • Thrashing in Operating System affects the performance of execution. Now in this thrashing tutorial, we will learn about the causes of Thrashing.
  • Initially, when the CPU utilization is low, then the process scheduling mechanism loads many processes into the Memory simultaneously so that the Degree of Multiprogramming can be increased.
  • In this situation, we have more processes than the available number of frames in Memory. Allocation of the limited amount of frames to each process.
  • When any higher priority Process arrives in Memory and if the frame is not freely available at that time, then the other process that occupied the frame which resides in the frame will move to secondary storage, and this free frame is now allocated to a newly arrived higher priority process.
  • In other words, we can say that as the Memory fills up, the process starts to spend a lot of time for the required pages to be swapped in; again, CPU utilization becomes low because most of the processes are waiting for pages.

Also Read  – Harekala Hajabba Biography

How to Overcome Thrashing?

In the previous section, we learned about the various causes of thrashing in os. Now in this section  we will see how to eliminate Thrashing? Here we will study the technique or methodology used to reduce the Thrashing.

  • To prevent Thrashing in operating system at first, we need to know how many frames a process needs at any time?
  • A technique known as a working-set model, which is used to reduce the causes of thrashing in os.
  • Working Model Set technique starts by looking at how frames a process is using. This technique specifies a locality model for process execution.
  • Virtual Memory is also responsible for Thrashing when several frames are not available.
  • According to the locality model, when a process executes, it moves from Locality to Locality. Here the term locality represents a set of pages that are actively used together.

thrashing in operating system

Tips– As the degree of multiprogramming increases to increase the CPU Utilization, it causes Thrashing after some time. This is as shown in the above picture.

What is Working Set Model ?

In this part of this thrashing tutorial, I will discuss the working set model explanation, which is a technique to reduce the Thrashing in os. The working set model is based on the assumption of Locality. This model used a parameter Δ defines the working-set window.

The concept is to check the most recent Δ page references.

  • The working set is a set of pages available in the most recent Δ or sometimes also known as an approximation of the Program’s Locality.
  • If the page is inactive, use it will be in the working set. If it is no longer being used, it will be dropped from the working set Δ time units after its last reference. So the working set is an approximation of the program’s Locality.

Working Set Model Example

In this section of the causes of thrashing tutorial, we will understand the working set model concept to deal with the help of an example that considers the sequence of memory references shown in the following Figure.

causes of thrashing in os

If 6 = 10 memory references, then the working set at time t1 is {1, 2, 5,6, 7}. At time t2, the working set has changed to {3, 4}.

The accuracy of the working set depends on the selection of 6. Assuming that six is too small, it will not encompass the whole Locality; but if 6 is too large, it may overlap several localities.

The main property of the working set is its size. If we compute the working-set size, WSS for each process in the system, we can then consider that where D is the total demand for frames, each process uses the pages in its working set.

Thus process I need WSS frames.

If the total demand is greater than the total number of available frames (D > m), it will cause Thrashing to occur, because in this case, some processes will not have enough frames. Once has been selected, we can use this model easily.

Here, the operating system’s role is that the operating system monitors the working set of each process, and after that, it allocates to that working set enough frames to provide it with its working-set size.

If we have sufficient extra frames, then another process can be initiated. It is important to remember that if the sum of the working-set sizes increases and exceeds the total number of available frames, then the operating system selects a process to suspend.

The process’s pages are swapped out, and its frames are reallocated to other processes, and the suspended process can be restarted later.

Conclusion and Summary

So as a conclusion, we can say that the working-set model prevents Thrashing in os while keeping the degree of multiprogramming as high as possible. In this way, it optimizes CPU utilization ( one of the important CPU Scheduling Criteria)

The main problem with the working-set model in os is keeping track of the working set.

Because the working-set window is a moving window and at each memory reference, a new reference appears at one end, and the oldest reference drops off the other end.

A page is in the working set if it is referenced anywhere in the working-set window.

Here in this causes of thrashing in os tutorial, we have discussed the following points

  • Thrashing in Operating System.
  • Causes of Thrashing.
  • How to overcome Thrashing?
  • Working Set Model.

I kindly request to readers, please give your feedback and suggestion. If you find any mistake in this tutorial, then comment.

Don’t stop learning and practice.

Also Read – Top 100 Data Structures and Algorithms Interview Questions

Leave a Reply

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