What is Continuous Memory Allocation?
Contiguous memory allocation is a classic memory allocation model that allocates consecutive blocks of memory (ie blocks of memory with consecutive addresses) to a process.
Contiguous memory allocation is one of the oldest memory allocation schemes. When a process needs to run, memory is requested from the process. The size of the process is compared to the amount of contiguous main memory available to run the process. If enough contiguous memory is found, memory is allocated to the process to start running. Otherwise, it is added to a queue of waiting processes until there is sufficient contiguous memory available.
The contiguous memory allocation scheme can be implemented in operating systems using two registers known as base and limit registers. When a process is running in main memory, its base register contains the starting address of the memory location where the process is running, while the amount of bytes used by the process is stored in the limit register.
A process does not directly refer to the actual address of a corresponding memory location. Instead, it uses a relative address with respect to its base register. All addresses specified by a program are considered virtual addresses. The CPU generates the logical or virtual address, which is converted into an actual address with the help of the Memory Management Unit (MMU). The base address register is used for address translation by the MMU. So,
Physical address = base register address + logical address / virtual address
The address of a location referenced by a process is checked to ensure that it does not refer to an address of a neighboring process. This processing security is taken over by the underlying operating system.
A disadvantage of contiguous memory allocation is that it reduces the amount of multiple programming due to processes waiting for free memory.