0% found this document useful (0 votes)
13 views3 pages

Understanding Thrashing in Operating Systems

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Understanding Thrashing in Operating Systems

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Thrashing:

Thrashing in operating system is a phenomenon that occurs in computer


systems when the system spends an excessive amount of time on page
swapping rather than executing useful work.

Thrashing is caused by a high level of page faults, which happens when the
system needs to retrieve a page from the disk because it is not present in
memory. Thus, thrashing in operating system is sometimes referred to as disk
thrashing.

NOTE: (To understand thrashing,


first, we need to know about page fault
and swapping.

o Page fault: We know every


program is divided into some pages. A
page fault occurs when a program
attempts to access data or code in its
address space but is not currently located in the system RAM.
o Swapping: Whenever a page fault happens, the operating system will
try to fetch that page from secondary memory and try to swap it with
one of the pages in RAM. This process is called swapping.)

Causes of thrashing: A high degree of multiprogramming and lack of frames


are two main causes of thrashing in the Operating system.

At the time, when thrashing starts then the operating system tries to apply
either the Global page replacement Algorithm or the Local page
replacement algorithm.
Global Page Replacement: The Global Page replacement has access to bring
any page, whenever thrashing found it tries to bring more pages. Actually,
due to this, no process can get enough frames and as a result, the thrashing
will increase more and more. Thus the global page replacement algorithm is
not suitable whenever thrashing happens.
Local Page Replacement: The local page replacement will select pages which
only belongs to that process. Due to this, there is a chance of a reduction in
the thrashing.
Techniques to Prevent Thrashing: The Local Page replacement is superior
to the Global Page replacement, although it has several drawbacks and is not
always useful. As a result, here are some more strategies for dealing with
Thrashing.

IT-Ramesh 9848353570 1
Working-Set Model: As mentioned, the working-set model is based on the
assumption of locality. This model uses a parameter, Δ, (Delta) to define the
working-set window.
The idea is to examine the most recent Δ page references. The set of pages in
the most recent Δ page references is the working set.

If a page is in active use, it will be in the working set. If it is no longer being


used, it will drop from the working set Δ time units after its last reference.

For example, given the


sequence of memory
references shown in
diagram, if Δ = 10 memory
references, then the
working set at time t1 is {1,
2, 5, 6, 7}. By time t2, the working set has changed to {3, 4}.

The accuracy of the working set depends on the selection of Δ. If Δ is too


small, it will not encompass the entire locality; if Δ is too large, it may overlap
several localities.

The most important property of the working set, is its size. If we compute the
working-set size, WSSi, for each process in the system, we can then consider
that D = ∑WSSi.

where D is the total demand for frames. Each process is actively using the
pages in its working set. Thus, process i needs WSSi frames. If the total
demand is greater than the total number of available frames (D > m),
thrashing will occur, because some processes will not have enough frames.

Page-Fault Frequency:
This is a straightforward model. We must act depending on the
frequency/rate of page faults and assign frames to each process accordingly.
For this page-fault rate, we specified an upper bound (UB) and a lower bound
(LB). We compare the page fault
rate(R) of each process to the stated
upper bound(UB) and lower
bound(LB).

If R > UB, we can assume that a


process requires additional frames to
keep this rate under control. To avoid
thrashing, we'll need to dedicate extra frames to it. If there aren't any frames

IT-Ramesh 9848353570 2
available, the process can be paused until a sufficient number of frames
becomes available.

We have more than enough frames for a process if R < LB, and some of them
can be given to other processes. We can maintain a balance between frame
needs and frame allocation by using the R, UB, and LB.

IT-Ramesh 9848353570 3

You might also like