Assignment 05
Assignment 05
Assignment # : 05
Internal Fragmentation
External Fragmentation
Data Fragmentation
Cause of fragmentation:
User processes are loaded and removed from the main memory, processes are stored in the
blocks of main memory. At the time of process loading and swapping there are many spaces
left which are not capable to load any other process due to their size.
Due to the dynamical allocation of main memory processes, main memory is available but
its space is not sufficient to load any other process.
1) Internal Fragmentation:
In this fragmentation, the process is allocated a memory block of size more than the size of
that process. Due to this some part of the memory is left unused and this cause internal
fragmentation.
Example: Suppose there is fixed partitioning (i.e. the memory blocks are of fixed sizes) is
used for memory allocation in RAM. These sizes are 2MB, 4MB, 4MB, 8MB. Some part of this
RAM is occupied by the Operating System (OS).
Now, suppose a process P1 of size 3MB comes and it gets memory block of size 4MB. So, the
1MB that is free in this block is wasted and this space can’t be utilized for allocating memory to
some other process. This is called internal fragmentation.
How to remove internal fragmentation?
This problem is occurring because we have fixed the sizes of the memory blocks. This problem
can be removed if we use dynamic partitioning for allocating space to the process. In dynamic
partitioning, the process is allocated only that much amount of space which is required by the
process. So, there is no internal fragmentation.
2) External Fragmentation:
In this fragmentation, although we have total space available that is needed by a process still
we are not able to put that process in the memory because that space is not contiguous. This is
called external fragmentation.
Example: Suppose in the above example, if three new processes P2, P3, and P4 come of sizes
2MB, 3MB, and 6MB respectively. Now, these processes get memory blocks of size 2MB, 4MB
and 8MB respectively allocated.
So, now if we closely analyze this situation then process P3 (unused 1MB)and P4(unused
2MB) are again causing internal fragmentation. So, a total of 4MB (1MB (due to process P1) +
1MB (due to process P3) + 2MB (due to process P4)) is unused due to internal fragmentation.
Now, suppose a new process of 4 MB comes. Though we have a total space of 4MB still we
can’t allocate this memory to the process. This is called external fragmentation.
3) Data fragmentation:
This type of fragmentation occurs when a group of data in memory is broken up into
many pieces that are not contiguous that is not close together.
If we are attempting to insert a large object into memory that has already suffered
then external fragmentation occurs.
Example:In a file system files are arranged in units called clustersblocks. There is a free
space to store files in these blocks in a contiguous manner.
In this way, we can do a rapid sequential file reads and writes. As files are added, deleted,
and modified or changed in size, there are external fragmentation occurs, and there are
only small holes in which we can place new data.
when a current file is enlarged, the operating system places the new data a in new non-
contiguous data blocks to fit into the available holes. New data blocks don't need to be
contiguous. This process slowing access cause of seek time and rotational latency of the
read/write head and incurring additional overhead to organize additional locations. This
is file system fragmentation.