Fragmentation in OS
Fragmentation in OS
An unwanted problem with operating systems is fragmentation, which occurs when processes load and
unload from memory and divide available memory. Because memory blocks are so small, they cannot be
assigned to processes, and thus remain idle. It’s also important to realize that programs create free space
or holes in memory when they are loaded and unloaded. Because additional processes cannot be assigned
to these little pieces, memory is used inefficiently. The memory allocation scheme determines the
fragmentation circumstances.
Types of Fragmentation
There are two main types of fragmentation:
Internal Fragmentation
External Fragmentation
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, if a system allocates a 64KB block of memory to store a file that is only 40KB in size, that
block will contain 24KB of internal fragmentation.
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.
Advantages
There are various advantages of fragmentation. Some of them are as follows:
Storage optimization
The fragmented systems might make potentially better use of the storage devices by using every storage
block available to us.
Fewer failures
If a system has insufficient sequential space, then it won’t support fragmentation and would ultimately fail.
No issues would arise.
Disadvantages
There are various disadvantages of fragmentation. Some of them are as follows:
Fixed Partitioning
The earliest and one of the simplest technique which can be used to load more than one processes into the
main memory is Fixed partitioning or Contiguous memory allocation.
In this technique, the main memory is divided into partitions of equal or different sizes. The operating
system always resides in the first partition while the other partitions can be used to store user processes. The
memory is assigned to the processes in contiguous way.
In fixed partitioning,
Dynamic Partitioning
Dynamic partitioning tries to overcome the problems caused by fixed partitioning. In this technique, the
partition size is not declared initially. It is declared at the time of process loading.
The first partition is reserved for the operating system. The remaining space is divided into parts. The size of
each partition will be equal to the size of the process. The partition size varies according to the need of the
process so that the internal fragmentation can be avoided.