Contiguous Memory Allocation - operating system tutorial


Today we will be discussing about Contiguous Memory Allocation - operating system tutorial in depth. So, let's start. shall we?

Contiguous Memory Allocation - operating system tutorial


In contiguous memory allocation we have to solve 2 major problems. First, is space allocation which means how we can store the data in contiguous fashion. Second, is the address translation which means CPU generates a logical address which should be used to access secondary memory then how to translate logical address to physical address to access main memory. So first we'll see about space allocation policy.

Space allocation in Contiguous Memory

If there is a process P1 in secondary memory then if P1 is brought to main memory then P1 will be allocated space in a contiguous fashion. If there is a 10 KB memory then we partition in fixed sized partitions but the size of all the partitions may not be same among themselves. So, this approach of partitioning is called fixed sized partitioning.

Fixed Sized Partitioning

In Fixed Sized Partitioning we partition the memory and the size of each partition is fixed and it cannot be changed.

Contiguous Memory Allocation - operating system tutorial

For example: When you go in a restaurant you see that the there are multiple dinner tables. So restaurant's capacity is divided into multiple tables but is it necessary that each table has same capacity? No, there are come tables for couples, some tables for families and all.

Drawback of Fixed Sized Partition

Now if a process P of size 4KB is to be placed in the above picture then there is only one partition of 5KB where it can be placed. When 4Kb process is placed in the 5Kb slot then 1 Kb will be left which leads to internal fragmentation. So, this is a major drawback of fixed sized partitioning that you cannot reuse a partition and internally space can be wasted.

Variable Sized Partitioning

To remove the drawback of fixed sized partitioning, variable sized partitioning was introduced. In variable size partition we do not partition the memory. So whenever a process will come we will allocate the space to it in the memory if memory can accomodate it.
Let say the size of memory is 10KB. Then a process P1 needs 4KB. So we will allocate 4KB to P1 and now remaining size will be 6KB. Let say P2 needs 3KB. So we will allocate 3KB to P2 and we are now left with 3KB.
We do not encounter internal fragmentation in variable size partition.

Conclusion

In the last post we read that contiguous memory allocation suffers from External Fragmentation. Contiguous Memory Allocation has 2 space allocation methods - Fixed Sized Partitioning and Variable Sized Partitioning. Fixed Sized Partitioning suffers from Internal Fragmentation.
This was all about Contiguous Memory Allocation - operating system tutorial .


Post a Comment (0)
Previous Post Next Post