The generic technique to use is called hardware-based address translation, or just address translation. The hardware transforms each memory access. changing their virtual address provided by the instruction to a physical address where the desired information is actually located. I.E the address were translated on every memory reference.
For the hardware to correctly translate the memory, OS need to manage memory: keeping track of which locations are free and which are in use, and carefully intervening to maintain control over how memory is used.
For simplicity, let’s first consider that each user’s address space must be placed contiguously in physical memory, each of the address space is less than the size of the physical memory and they are the same size.
also known as base and bounds
Use 2 register within each CPU, one called the base and the other called bounds(sometimes called a limit). The base-and-bounds pair is going to allow us to place the address space anywhere we’d like in physical memory, and they will set the address space for certain processes.
When the process is running, whenever there’s a memory reference, the translation will happen in the following manner
$$ \text{physical adress = virtual adress + base} $$
Because this relocation of the address happens at runtime, and because we can move address spaces even after the process has started running, the technique is often referred to as dynamic relocation
The bound register are used for protection. If a process generates a virtual address that’s greater than the bounds or negative, the CPU will raise an exception and the process will likely to be terminated.
The base and bounds register are hardware structures kept on the chip. And the part of the processor that helps with the address translation the MMU(Memory Management Unit).
With address translation, the OS can control each and every memory access from a process, ensuring the accesses stay within the bounds of the address space. Key to the efficiency of this technique is hardware support, which performs the translation quickly for each access, turning virtual addresses (the process’s view of memory) into physical ones (the actual view). All of this is performed in a way that is transparent to the process that has been relocated; the process has no idea its memory references are being translated, making for a wonderful illusion.