There are two types of fragmentation in OS which are given as: Internal fragmentation, and External fragmentation.
Internal fragmentation happens when the memory is split into mounted sized blocks. Whenever a method request for the memory, the mounted sized block is allotted to the method. just in case the memory allotted to the method is somewhat larger than the memory requested, then the distinction between allotted and requested memory is that the Internal fragmentation.
The above diagram clearly shows the internal fragmentation because the difference between memory allocated and required space or memory is called Internal fragmentation.
External fragmentation happens when there’s a sufficient quantity of area within the memory to satisfy the memory request of a method. however the process’s memory request cannot be fulfilled because the memory offered is during a non-contiguous manner. Either you apply first-fit or best-fit memory allocation strategy it’ll cause external fragmentation.
In above diagram, we can see that, there is enough space (55 KB) to run a process-07 (required 50 KB) but the memory (fragment) is not contiguous. Here, we use compaction, paging or segmentation to use the free space to run a process.
Difference between Internal fragmentation and External fragmentation:-
S.NO Internal fragmentation External fragmentation 1. In internal fragmentation fixed-sized memory, blocks square measure appointed to process. In external fragmentation, variable-sized memory blocks square measure appointed to method. 2. Internal fragmentation happens when the method or process is larger than the memory. External fragmentation happens when the method or process is removed. 3. The solution of internal fragmentation is best-fit block. Solution of external fragmentation is compaction, paging and segmentation. 4. 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. 5. 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, is called External fragmentation .
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.