Address Binding¶
When to do address binding?¶
Compile Time¶
- Compiler translates symbolic code to absolute code
- The base address is hardcoded
Load Time¶
- After compiling, we have a base address
- The memory addresses in the code are written as a offset of the base address
- Then the loader will calculate all the addresses of the code
- If starting location changes then we have to reload the code
Run Time¶
- Translates symbolic code into virtual-address code
- Need special hardware (Memory-Management Unit) (don't want to waste CPU cycle to do this)
- Most general-purpose OS use this method
Memory-Management Unit (MMU)¶
- Hardware that maps virtual to physical address
- Relocation register is added to every address
IOMMU (for enabling GPU passthrough in KVM/QEMU) is similar device that translates the virtual address to physical address to enable DMA for io devices (GPU).
Virtual vs. Physical Address¶
- virtual address is generated by CPU
- physical address is seen by the memory module
- compile time and load time address binding : virtual address \(=\) physical address
- Execution time address binding : virtual address \(\neq\) physical address
- The user program deals with logical addresses; it never sees the real physical address