C Contiguous Memory



What is Contiguous Memory ?

  1. When Big Block of memory is reserved or allocated then that memory block is called as Contiguous Memory Block.
  2. Alternate meaning of Contiguous Memory is continuous memory.
  3. 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

  1. Two registers are used while implementing the contiguous memory scheme. These registers are base register and limit register.
  2. 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

contiguous memory

Here diagram 1 represents the contiguous allocation of memory and diagram 2 represents non-contiguous allocation of memory

  1. 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 ?

  1. Using static array declaration.
  2. 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.