0% found this document useful (0 votes)
60 views

Assignment 05

The document contains information about Umar Ali, a student enrolled in the 6th semester of a BS in Computer Science program. It provides details of an assignment submitted to Sir Tariq on the topic of "CS-512 Distributed Database". The document then defines and discusses three types of fragmentation in computer memory: internal fragmentation, external fragmentation, and data fragmentation.

Uploaded by

Dil Nawaz
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)
60 views

Assignment 05

The document contains information about Umar Ali, a student enrolled in the 6th semester of a BS in Computer Science program. It provides details of an assignment submitted to Sir Tariq on the topic of "CS-512 Distributed Database". The document then defines and discusses three types of fragmentation in computer memory: internal fragmentation, external fragmentation, and data fragmentation.

Uploaded by

Dil Nawaz
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

Name : Umar Ali

Roll Number : 522

Class # : BS (CS) – 6th Semester

Assignment # : 05

Submitted to : Sir Tariq

Subject : “CS-512 Distributed


Database”
Fragmentation:
` Fragmentation is an unwanted problem where the memory blocks
cannot be allocated to the processes due to their small size and the blocks remain unused.
Fragmentation is an unwanted problem where the memory blocks cannot be allocated to the
processes due to their small size and the blocks remain unused. It can also be understood as
when the processes are loaded and removed from the memory they create free space or hole in
the memory and these small blocks cannot be allocated to new upcoming processes and results
in inefficient use of memory. Basically, there are three types of fragmentation:

 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.

How to remove external fragmentation?


This problem is occurring because we are allocating memory continuously to the
processes. So, if we remove this condition external fragmentation can be reduced. This is what
done in paging & segmentation(non-contiguous memory allocation techniques) where
memory is allocated non-contiguously to the processes. We will learn about paging and
segmentation in the next blog.

Another way to remove external fragmentation is compaction. When dynamic partitioning is


used for memory allocation then external fragmentation can be reduced by merging all the
free memory together in one large block. This technique is also
called defragmentation. This larger block of memory is then used for allocating space
according to the needs of the new processes.

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.

You might also like