0% found this document useful (0 votes)
49 views6 pages

OS-Fragmentation

Uploaded by

Sourav Kumar
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)
49 views6 pages

OS-Fragmentation

Uploaded by

Sourav Kumar
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
You are on page 1/ 6

Operating System

Topperworld.in

fregmentation in os

Fragmentation
• Fregmentation is an unwanted problem in the operating system in
which the processes are loaded and unloaded from memory, and free
memory space is fragmented.
• Processes can't be assigned to memory blocks due to their small size,
and the memory blocks stay unused.
• It is also necessary to understand that as programs are loaded and
deleted from memory, they generate free space or a hole in the
memory.
• These small blocks cannot be allotted to new arriving processes,
resulting in inefficient memory use.
• The conditions of fragmentation depend on the memory allocation
system.
• As the process is loaded and unloaded from memory, these areas are
fragmented into small pieces of memory that cannot be allocated to
incoming processes. It is called fragmentation.

What is Memory Partitioning?


✓ This is the technique of memory management where the main memory
is divided into various partitions/blocks so that many processes can be
present in the memory simultaneously.
There are mainly two types of partitioning.
Fixed Partitioning
Dynamic Partitioning

©Topperworld
Operating System

Fixed Partitioning:

• In the Fixed Partitioning, the main memory is divided into fixed-sized


partitions/blocks.
• The partitions/blocks can be of the same size or different sizes.
• The size of the partition/block is decided before the process arrives
in the main memory.
The diagram below shows how the main memory is partitioned using
fixed partitioning.

In the diagram above you can see that we have 4 blocks of fixed size.
Now since the number of partitions/blocks is fixed, the number of processes
that can reside in the main memory is also fixed and at max, it can be equal
to the number of partitions/blocks. Hence the degree of multiprogramming
in fixed partitioning is limited to the number of partitions/blocks in the main
memory.

©Topperworld
Operating System

Dynamic Partitioning:

• In Dynamic Partitioning, the main memory is not divided initially.


• When a process arrives in the main memory it is given that much
memory. Here the partition/block size is not fixed initially, instead, the
size of partition/block size is equal to the size of the process.
This is shown in the diagram below.

Types of Fragmentation
There are mainly two types of fragmentation in the operating system. These
are as follows:
➢ Internal Fragmentation
➢ External Fragmentation

©Topperworld
Operating System

Internal Fragmentation:

• When a process is allocated to a memory block, and if the process is


smaller than the amount of memory requested, a free space is created
in the given memory block.
• Due to this, the free space of the memory block is unused, which causes
internal fragmentation.
For Example:
Assume that memory allocation in RAM is done using fixed partitioning (i.e.,
memory blocks of fixed sizes). 2MB, 4MB, 4MB, and 8MB are the available
sizes. The Operating System uses a part of this RAM.

Let's suppose a process P1 with a size of 3MB arrives and is given a


memory block of 4MB. As a result, the 1MB of free space in this block is
unused and cannot be used to allocate memory to another process. It is
known as internal fragmentation.

©Topperworld
Operating System

External Fragmentation
• External fragmentation happens when a dynamic memory allocation
method allocates some memory but leaves a small amount of memory
unusable.
• The quantity of available memory is substantially reduced if there is too
much external fragmentation.
• There is enough memory space to complete a request, but it is not
contiguous. It's known as external fragmentation.

For Example:

In the above diagram, you can see that there is sufficient space (50 KB)
to run a process (05) (need 45KB), but the memory is not contiguous. You
can use compaction, paging, and segmentation to use the free space to
execute a process.

©Topperworld
Operating System

Advantages and disadvantages of fragmentation


Advantages
There are various advantages of fragmentation. Some of them are as
follows:
✓ Fast Data Writes
✓ Fewer Failures
✓ Storage Optimization
Disadvantages
✓ Need for regular defragmentation
✓ Slower Read Timesa.

©Topperworld

You might also like