It is the situation where process spends more time in processing page faults than executing instructions of processes.

  • Thrashing degrades the performance of system.
  • There can be a situation when memory is full of pages that are accesssed frequently. A page fault will occur if the required page is not present.
  • In order to make space for swapping in the required page, one of the frequently accessed page is swapped out from main
  • Soon the page is swapped out is required for execution and this again results in page fault.
  • Thus a series of page fault occur and swapping becomes a large overhead.
  • Thrashing generally occurs in multitasking os. As there are several processes running at same time, so memory becomes overcommitted so it leads to thrashing.

In other way thrashing is directly related to degree of multiprogramming and it can occur in following manner:-

  1. When a global page replacement algo is used then it replaces pages with no regard to process to which they belong.
  2. After increasing the degree of multiprogramming, if a particular process enter a new phase, it may need more frames.
  3. Under these circumstances, this process starts faulting and takes away frames from other processes.
  4. These processes need those pages, however and so they also fault and take frames from other processes.
  5. All these faulting processes then queues up for the paging device to swap pages in and out. As processes wait for paging device, cpu utilization decreases.
  6. When cpu scheduler sees the decrease in cpu utilization, it increases the degree of multiprogramming. Thus new processes enter the system and take the frames from running processes. This results in more page faults and longer queue for paging
  7. As a result, cpu utilization drops even further and thrashing sets in.

The performance of system is satisfactory to certain extent. When degree of multiprogramming is increased, it lead to thrashing and system performance degrades.

Thrashing Diagram
Thrashing Diagram

Methods to handle thrashing:-

Various methods to handle thrashing:-

  1. The os attempts to recover from thrashing by suspending the execution of current processes and preventing the execution of new process to start.
  2. Thrashing can be removed by selecting an appropriate page replacement algo.
  3. Thrashing can be avoided by using local page replacement algo. With local replcement, the process cannot take frames from another process. It just selects and swaps the page which belongs to the same process.
  4. Thrashing can also be prevented by allocating a process as many frames as it needs.

(Visited 44 times, 1 visits today)

Written by: