Meaning of Fragmentation
In the words of layman, Fragmentation means isolated or incomplete part. Fragmentation means something is broken into parts that are detached, isolated or incomplete.
Types of Fragmentation
There are two types of Fragmentation :-
1) External Fragmentation
2) Internal Fragmentation
a) It exists when there us enough total memory space available to satisfy a request, but available memory space are not contiguous.
b) Storage space is fragmented into large number of small holes.
c) Both first fit and best fit strategies suffer from this.
d) First fit is better in some systems, whereas best fit is better for other.
e) Depending on the total amount of memory storage, size, external fragmentation may be minor or major problem.
f) Statistically N allocated block, Another 0.5 N blocks will be lost to fragmentation. The 1/3 of memory is unusable. It is called 50 - Percent Rule
Consider a multiple partition allocation scheme with a hole of 18,462 bytes. The next process request with 18,462 bytes. If we allocate, we are left with a hole of 2 bytes.
The general approach to avoid this problem is to :-
a) Break physical memory into fixed sized blocks and allocate memory in units based on block size.
b) Memory allocated to a process may be slightly large than the requested memory.
* The difference between two numbers is Internal fragmentation.
Solution to Internal Fragmentation
The goal is to shuffle the memory content. so as to place all free memory together in one large block.
It is not always possible due to :-
If relocation is static and done at assembly or load time
It is possible
Only if relocation is dynamic and is done at execution time
2) Permit the logical address space to the processes to be non-contagious.
Its very easy to understand the guidance given in this article on types of fragmentation. Thanks for notes.