FOR FREE CONTENT

How Non-contiguous Memory Allocation work

 

Let’s take an example that how non-contiguous memory allocation work, let we have three processes

P1 with size 8KB, P2 with size 16KB, and P3 with size 8KB. Here main memory size is 32KB.

 

# Every process divided into pages of the same size like 2KB. So, the size of every page is 2KB and the same as each memory frame size is 2KB. 

 

Assume the initial entire memory is free and three processes  P1, P2, P3 want to get memory than processes obviously allocate contiguous manner, because not require to allocate as non-contiguous way because memory is free, so, P1, P2, P3 allocate contiguously as memory is entirely free.

 

 

# Now assume that process P2 and P3 has been finished or block (for I/O operation), so, they swap out from memory and create a chance for other processes, assume that process P4 comes with size 14 KB, so,

 

# P1 individually free 8KB (4 frames) and P3 individually free 8KB (4 frames), but if see above the memory picture 8KB+8KB=16KB (8 frames) will not free contiguously or consecutively. 

 

# So, here because of not enough space to allocate P4 in a place contiguous manner, it allocates two places of memory a non-contiguous manner.

 

 

There are three fundamental approaches to implementing non-contiguous memory allocation:

 

1.  Paging

2.  Segment 

3.  Paging with the segment