C Contiguous MemoryPritesh
What is Contiguous Memory ?
- When Big Block of memory is reserved or allocated then that memory block is called as Contiguous Memory Block.
- Alternate meaning of Contiguous Memory is continuous memory.
- Suppose inside memory we have reserved 1000-1200 memory addresses for special purposes then we can say that these 200 blocks are going to reserve contiguous memory.
Contiguous Memory Allocation
- Two registers are used while implementing the contiguous memory scheme. These registers are base register and limit register.
- When OS is executing a process inside the main memory then content of each register are as –
|Register||Content of register|
|Base register||Starting address of the memory location where process execution is happening|
|Limit register||Total amount of memory in bytes consumed by process|
Here diagram 1 represents the contiguous allocation of memory and diagram 2 represents non-contiguous allocation of memory
- When process try to refer a part of the memory then it will firstly refer the base address from base register and then it will refer relative address of memory location with respect to base address
How to allocate contiguous memory ?
- Using static array declaration.
- Using alloc() / malloc() function to allocate big chunk of memory dynamically.
This article could be more useful for understanding the memory management concept in operating system.