top of page

Fragmentation in OS: Internal Fragmentation and External Fragmentation

Fragmentation is a process of data storage in which memory space is used inadequately, decreasing ability or efficiency and sometimes both." The precise implications of fragmentation depend on the specific storage space allocation scheme in operation and the particular fragmentation type. In certain instances, fragmentation contributes to "unused" storage capacity, and the concept also applies to the unusable space generated in that situation. The memory used to preserve the data set (- for example file format) is similar for other systems (- for example, the FAT file system), regardless of the amount of fragmentation (from null to the extreme).



Internal Fragmentation

Internal Fragmentation is a problem that occurs when the process is allocated to a memory block whose size is more than the size of that process and due to which some part of the memory is left unused. Thus the space wasted inside the allocated memory block is due to the restriction on the allowed sizes of allocated blocks.




Solution

The solution of internal fragmentation is the best-fit block.


Best -Fit Block

This method keeps the free/busy list in order by size – smallest to largest. In this method, the operating system first searches the whole of the memory according to the size of the given job and allocates it to the closest-fitting free partition in the memory, making it able to use memory efficiently. Here the jobs are in the order from smallest job to largest job.



External Fragmentation

When the memory space in the system can easily satisfy the requirement of the processes, but this available memory space is non-contiguous, So it can’t be utilized further. Then this problem is referred to as External Fragmentation.


Suppose, we want to allocate memory to a process of size 8 MB and as In the above diagram, we can see that, there is enough space that is 9 MB to run a process of size 8MB but the memory that is fragments are not contiguous.


Solution

There is a solution for the problem of External Fragmentation and it is Compaction and Paging


Compaction

It is a process in which the free space is collected in a large memory chunk to make some space available for processes. In memory management, swapping creates multiple fragments in the memory because of the processes moving in and out. Compaction refers to combining all the empty spaces together and processes.


Paging

It is a storage mechanism that allows OS to retrieve processes from the secondary storage into the main memory in the form of pages. In the Paging method, the main memory is divided into small fixed-size blocks of physical memory, which is called frames. The size of a frame should be kept the same as that of a page to have maximum utilization of the main memory and to avoid external fragmentation. Paging is used for faster access to data, and it is a logical concept.



Difference Between External Fragmentation and Internal Fragmentation

INTERNAL FRAGMENTATION

EXTERNAL FRAGMENTATION

In internal fragmentation fixed-sized memory, blocks square measure appointed to process.

In external fragmentation, variable-sized memory blocks square measure appointed to the method.

Internal fragmentation happens when the method or process is larger than the memory.

External fragmentation happens when the method or process is removed.

Internal fragmentation occurs when memory is divided into fixed-sized partitions.

External fragmentation occurs when memory is divided into variable size partitions based on the size of processes.

The difference between memory allocated and required space or memory is called Internal fragmentation.

The unused spaces formed between non-contiguous memory fragments are too small to serve a new process, which is called External fragmentation.

It occurs on the allocation of a process to a partition greater than the process’s requirement. The leftover space causes degradation system performance.

It occurs on the allocation of a process to a partition greater which is exactly the same memory space as it is required.

The solution of internal fragmentation is the best-fit block.

The solution to external fragmentation is compaction and paging.

Internal fragmentation occurs with paging and fixed partitioning.

External fragmentation occurs with segmentation and dynamic partitioning.


Read More:




The Tech Platform

0 comments

Comments


bottom of page