You are on page 1of 13

OPERATING SYSTEM

Thrashing

• In global replacement, a high priority process can take frames from a low
priority process.
• If the number of frames allocated to a low priority process falls below the
minimum number of required by the computer architecture then we must
suspend that process’s execution.
• If the process does not have the number of frames it needs to support
pages in active use, it will quickly page fault.
• At this time, it must replace some page. Since all its pages are in active
use, it must replace a page that will be needed again right away.
• Consequently, it quickly faults again and again , and again, replacing pages
that it must bring back in immediately.
Þ This high paging activity is called thrashing.
Þ A process is thrashing if it is spending more time on paging than
executing.

1
Thrashing: system is spending a major portion of its time in servicing the
page faults, but the actual processing done is very negligible.

C
6
A
8

C takes 2 B
frames 7 A takes 2 frames
from B from X using global
using replacement
global B takes 2 allocation policy.
replacem frames from
ent A using
allocation global
policy. replacement
allocation
2
policy.
OPERATING SYSTEM
Thrashing

• If a process does not have “enough” pages, the page-fault rate is


very high
 Page fault to get page
 Replace existing frame
 But quickly need replaced frame back
 This leads to:
Low CPU utilization
Operating system thinking that it needs to increase the
degree of multiprogramming
Another process added to the system

• Thrashing  a process is busy swapping pages in and out

3
OPERATING SYSTEM
Causes of Thrashing

4
Prevention of thrashing
• Working set model
• Page fault frequency

5
OPERATING SYSTEM
Prevention of Thrashing

Locality Model of Program execution


• A locality is a set of pages that are actively used together.
• A program is composed of several different localities, which may
overlap.
• Two types of locality:
• Temporal locality: the memory locations referenced recently and are
likely to be referenced again e.g. looping, subroutine calls, stacks etc.
• Spatial locality: once a memory location is referenced, it is highly
possible that the nearby locations will be referenced e.g. arrays.

6
OPERATING SYSTEM
Prevention of Thrashing

Working Set Model


• The working set model is based on the concept of locality, and
defines a working set window, of length delta. 
• Whatever pages are included in the most recent delta page
references are said to be in the processes working set window,
and comprise its current working set, as illustrated in diagram:-

7
OPERATING SYSTEM
Prevention of Thrashing

8
Working set model
• This technique prevents thrashing along with ensuring the highest
degree of multiprogramming possible. Thus, it optimizes CPU
utilisation.

9
OPERATING SYSTEM
Prevention of Thrashing

Working Set Model

Advantages:
•Working-set strategy prevents thrashing
• Degree of multiprogramming will be high

Disadvantages:
• Keeping track of working set
• Working set is a moving window
• Clumsy way to control thrashing

10
OPERATING SYSTEM
Prevention of Thrashing

Page Fault Frequency


• It is a direct approach to prevent thrashing.
• The problem associated with Thrashing is the high page fault rate
and thus, the concept here is to control the page fault rate
• When page fault rate is too high, it implies that the process needs
more frames.
• Conversely, if the page fault rate is too low, then the process may
have too many frames.
• A upper and lower bound can be established on the desirable
page fault rate.

11
12
Advantage
• Direct way to control thrashing
• Directly measures and control the page fault rate

13

You might also like