THRASHING


Thrashing is a state where the vast majority of the processing time is spent paging memory in and out of the system and very little is spent useful work. If this situation persists, then the system performance rapidly becomes unacceptable and will appear to the user to have hung.

Thrashing features
When thrashing occurs the device will appear to do nothing or 'hang' for period. Unlike a deadlock however, the device can recover from thrashing.

Prevention of thrashing
The following can be used reduce the chance of thrashing:

  • Compress pages in memory to decrease the amount of memory that has to be paged in and out
  • Limit the maximum size of each process's paged memory to the minimum size of the paging cache
  • Partition the page cache per-process and allocate pages to processes based on the Working Set Size (WSS) of threads in that process
  • Swap out the oldest pages in advance to free up memory to cope with spikes in paging demand
  • Don't let threads steal pages from other threads


Recovery from thrashing:

  • The possible courses of action to undertake  are :
  • Reboot the device
  • Kill a thread
  • Decrease the number of paged threads running concurrently
  • Pick one thread with a high page fault rate and stop other threads stealing pages from the thread's associated process
  • Prompt the user-side memory manager to close down applications.

How to eliminate thrashing:
To resolve hard drive thrashing you can do any of the suggestions below.

  • Increase the amount of RAM in the computer.
  • Decrease the number of programs being run on the computer.
  • Adjust the size of the swap file.

WORKING SET MODEL:

  • conceptual model proposed by Peter Denning to prevent thrashing.
  • Informal definition: the collection of pages a process is using actively, and which must thus be memory-resident to prevent this process from thrashing.
  • If the sum of all working sets of all runnable threads exceeds the size of memory, then stop running some of the threads for a while.
  • Divide processes into two groups: active and inactive:
  • When a process is active its entire working set must always be in memory: never execute a thread whose working set is not resident.
  • When a process becomes inactive, its working set can migrate to disk.
  • Threads from inactive processes are never scheduled for execution.
  • The collection of active processes is called the balance set.
  • The system must have a mechanism for gradually moving processes into and out of the balance set.
  • As working sets change, the balance set must be adjusted.

How to compute working sets:

  • Denning proposed a working set parameter T: all pages referenced in the last T seconds comprise the working set.
  • Can extend the clock algorithm to keep an idle time for each page.
  • Pages with idle times less than T are in the working set.

Page Fault Frequency:

  •  another approach to preventing thrashing.
  • Per-process replacement; at any given time, each process is allocated a fixed number of physical page frames.
  • Monitor the rate at which page faults are occurring for each process.
  • If the rate gets too high for a process, assume that its memory is overcommitted; increase the size of its memory pool.
  • If the rate gets too low for a process, assume that its memory pool can be reduced in size.
  • If the sum of all memory pools don't fit in memory, deactivate some processes.

In practice, today's operating systems don't worry much about thrashing:

With personal computers, users can notice thrashing and handle it themselves:

  • Typically, just buy more memory
  • Or, manage balance set by hand


Thrashing was a bigger issue for time sharing machines with dozens or hundreds of users:

  • System had to handle thrashing automatically.
  • Technology changes make it unreasonable to operate machines in a range where memory is even slightly overcommitted; better to just buy more memory.

No comments:

Post a Comment