Contiguous memory allocation
Last updated
Last updated
In contiguous memory allocation, there is a one-to-one correspondence between the logical address space of a process and its physical address space.
Consequences:
Limitation of the address space of a process – in no case can memory management support automatic mechanisms that allow the address space of a process to be larger than the size of the main memory available.
The use of overlays can allow overcoming that.
Contiguity of the physical address space – although it is not a strictly necessary condition, it is naturally simpler and more efficient to assume that the process address space is contiguous.
The swapping area is an extension of the main memory – it serves to store the address space of processes that cannot be resident into the main memory due to lack of space.
How are dynamic mapping and dynamic protection accomplished?
A piece of hardware (the MMU) is required.
The limit register must contain the size in bytes of the logical address space.
The base register must contain the address of the beginning of the main memory region where the physical address space of the process is placed.
On context switching, the dispatch operation loads the base and limit registers with the values present in the corresponding fields of the process control table entry associated with the process that is being scheduled for execution.
Whenever there is a reference to memory.
the logical address is first compared to the value of the limit register.
if it is less, it is a valid reference (it occurs within the process address space) then the logical address is added to the value of the base register to produce the physical address.
if it is greater than or equal, it is an invalid reference, then a null memory access (dummy cycle) is set in motion and an exception is generated due to address error.
When a process is created, the data structures to manage it is initialized.
Its logical address space is constructed, and the value of the limit register is computed and saved in the corresponding field of the process control table (PCT).
If there is space in main memory, its address space is loaded there, the base register field is updated with the initial address of the assigned region and the process is placed in the READY queue.
Otherwise, its address space is temporarily stored in the swapping area and the process is placed in the SUSPENDED-READY queue.
If memory is required for another process, a BLOCKED (or even READY) process may be swapped out, freeing the physical memory it is using.
In such a case, its base register field in the PCT becomes undefined.
If memory becomes available, a SUSPENDED-READY (or even SUSPENDED-BLOCKED) process may be swapped in.
Its base register field in the PCT is updated with its new physical location.
A SUSPENDED-BLOCK process is only selected if no SUSPENDED-READY one exists.
When a process terminates, it is swapped out (if not already there), waiting for the end of operations.