0% found this document useful (0 votes)
18 views2 pages

Thrashing

The document discusses the allocation of frames in operating systems, focusing on demand paging and the algorithms used for frame allocation, such as equal and proportional allocation. It also explains the concepts of global and local page replacement, highlighting their advantages and disadvantages, and introduces thrashing, which occurs when excessive page swapping degrades CPU performance. Solutions to thrashing include using local page replacement to maintain CPU utilization by restricting processes to their allocated memory partitions.

Uploaded by

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

Thrashing

The document discusses the allocation of frames in operating systems, focusing on demand paging and the algorithms used for frame allocation, such as equal and proportional allocation. It also explains the concepts of global and local page replacement, highlighting their advantages and disadvantages, and introduces thrashing, which occurs when excessive page swapping degrades CPU performance. Solutions to thrashing include using local page replacement to maintain CPU utilization by restricting processes to their allocated memory partitions.

Uploaded by

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

Allocation of Frame

An important aspect of operating systems, virtual memory is implemented using demand


paging. Demand paging necessitates the development of a page-replacement algorithm and
a frame allocation algorithm. Frame allocation algorithms are used if you have multiple
processes; it helps decide how many frames to allocate to each process.
There are various constraints to the strategies for the allocation of frames:
 You cannot allocate more than the total number of available frames.
 At least a minimum number of frames should be allocated to each process. This
constraint is supported by two reasons. The first reason is, as less number of frames
are allocated, there is an increase in the page fault ratio, decreasing the performance
of the execution of the process. Secondly, there should be enough frames to hold all
the different pages that any single instruction can reference.

Frame allocation algorithm:


The two algorithms commonly used to allocate frames to a process are:
1. Equal allocation: In a system with x frames and y processes, each process gets equal
number of frames, i.e. x/y. For instance, if the system has 48 frames and 9 processes,
each process will get 5 frames. The three frames which are not allocated to any
process can be used as a free-frame buffer pool.
 Disadvantage: In systems with processes of varying sizes, it does not make much
sense to give each process equal frames. Allocation of a large number of frames
to a small process will eventually lead to the wastage of a large number of
allocated unused frames.
2. Proportional allocation: Frames are allocated to each process according to the process
size.
For a process pi of size si, the number of allocated frames is ai = (si/S)*m, where S is the
sum of the sizes of all the processes and m is the number of frames in the system. For
instance, in a system with 62 frames, if there is a process of 10KB and another process
of 127KB, then the first process will be allocated (10/137)*62 = 4 frames and the other
process will get (127/137)*62 = 57 frames.
 Advantage: All the processes share the available frames according to their needs,
rather than equally.

Global vs Local Allocation –


The number of frames allocated to a process can also dynamically change depending on
whether you have used global replacement or local replacement for replacing pages in case
of a page fault.
1. Local replacement: When a process needs a page which is not in the memory, it can
bring in the new page and allocate it a frame from its own set of allocated frames only.
 Advantage: The pages in memory for a particular process and the page fault ratio
is affected by the paging behavior of only that process.
 Disadvantage: A low priority process may hinder a high priority process by not
making available to the high priority process its frames.
2. Global replacement: When a process needs a page which is not in the memory, it can
bring in the new page and allocate it a frame from the set of all frames, even if that
frame is currently allocated to some other process; that is, one process can take a
frame from another.
 Advantage: Does not hinder the performance of processes and hence results in
greater system throughput.
 Disadvantage: The page fault ratio of a process cannot be solely controlled by the
process itself. The pages in memory for a process depends on the paging
behavior of other processes as well.

Thrashing:

Page Fault and Swapping: A page fault occurs when the memory access requested (from
the virtual address space) does not map to something that is in RAM. A page must then be
sent from RAM to swap, so that the requested new page can be brought from swap to RAM.
This results in 2 disk I/Os. Now you might know that disk I/Os are very slow as compared to
memory access.

Thrashing: Now if it happens that your system has to swap pages at such a higher rate
that major chunk of CPU time is spent in swapping then this state is known as thrashing. So
effectively during thrashing, the CPU spends less time in some actual productive work and
more time in swapping.
Now the effects of thrashing and also the extent to which thrashing occurs will be decided
by the type of page replacement policy.

1. Global Page Replacement: The paging algorithm is applied to all the pages of the memory
regardless of which process "owns" them. A page fault in one process may cause a
replacement from any process in memory. Thus, the size of a partition may vary randomly.

2. Local Page Replacement: The memory is divided into partitions of a predetermined size
for each process and the paging algorithm is applied independently for each region. A
process can only use pages in its partition.

What happens after Thrashing starts?

If global page replacement is used, situations worsens very quickly. CPU thinks that CPU
utilization is decreasing, so it tries to increase the degree of multiprogramming. Hence
bringing more processes inside memory, which in effect increases the thrashing and brings
down CPU utilization further down. The CPU notices that utilization is going further down,
so it increases the degree of multiprogramming further and the cycle continues.
The solution can be local page replacement where a process can only be allocated pages in
its own region in memory. If the swaps of a process increase also, the overall CPU utilization
does not decrease much. If other transactions have enough page frames in the partitions
they occupy, they will continue to be processed efficiently.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy