8. 1 Background ●●● ●●●● ●●●●● ●●●● Binding of instructions and data to memory ●●0●● ●●●● ●●●● addresses can happen at three different stages ● Compile time If memory location known at compile time, absolute code can be generated must recompile code if starting location changes E.g. The MS-DOS. COM-format programs Load time +linkage time) If memory location is not known at com pile time Must generate re-locatable code if memory location is known at load time, absolute code can be generated at this time if starting location changes, only need reload the code
12 8.1 Background ⚫ Binding of instructions and data to memory addresses can happen at three different stages ⚫ Compile time ▪ If memory location known at compile time, absolute code can be generated ▪ must recompile code if starting location changes ▪ E.g. The MS-DOS .COM-format programs ⚫ Load time (+linkage time) ▪ If memory location is not known at compile time, Must generate re-locatable code ▪ if memory location is known at load time, absolute code can be generated at this time ▪ if starting location changes, only need reload the code
8. 1 Background ●●● ●●●● ●●●●● ●●●● Execution time ●●0●● ●●●0 ●●●● If memory location is not known at com pile time and o o load time, Binding is delayed until run time absolute code must be generated at run time, if the process can be moved during its execution from one memory segment to another Need hardware support for address mapping(e. g, base and limit registers) Most general-purpose os use this methoe
13 8.1 Background ⚫ Execution time ▪ If memory location is not known at compile time and load time, Binding is delayed until run time ▪ absolute code must be generated at run time, if the process can be moved during its execution from one memory segment to another ▪ Need hardware support for address mapping (e.g., base and limitregisters) ▪ Most general-purpose OS use this method
8. 1 Background ●●● ●●●● ●●●●● ●●●● ●●0●● Logical vs Physical Address space ●●●0 ●●●● Physical address The address seen by the memory unit(与物理内存单 元直接相关的地址,直接装入到寻址寄存器中的地址) o Load into the memory-address register of memory ● Logical address ● generated by the CPU o also referred to as virtual address
14 8.1 Background ⚫ Logical vs. Physical Address Space ⚫ Physical address ⚫ The address seen by the memory unit (与物理内存单 元直接相关的地址,直接装入到寻址寄存器中的地址) ⚫ Load into the memory-address register of memory ⚫ Logical address ⚫ generated by the CPU ⚫ also referred to as virtual address
8. 1 Background ●●● ●●●● ●●●●● ●●●● Logical and physical addresses are the same inooo ●●●● compile-time and load-time address-binding schemes o Before the run-time, addresses have been mapped to absolute code e In the run-time, addresses seen by cpu are identical to that seen by the memory unit logical (virtual) and physical addresses differ in execution-time address-binding scheme o re- locatable code are seen by CPU o absolute code are seen by the memory unit
15 8.1 Background ⚫ Logical and physical addresses are the same in compile-time and load-time address-binding schemes ⚫ Before the run-time, addresses have been mapped to absolute code ⚫ In the run-time, addresses seen by CPU are identical to that seen by the memory unit ⚫ logical (virtual) and physical addresses differ in execution-time address-binding scheme ⚫ re-locatable code are seen by CPU ⚫ absolute code are seen by the memory unit
8. 1 Background ●●● ●●●● ●●●●● ●●●● Memory-Management Unit (MMU ●●0●● ●●●0 ●●●● Hardware device that maps virtual address to physical address in the run-time o There are many different methods to accomplish such mapping In a simple MMU scheme, the value in the relocation register is added to every address generated by a user process(CPU)at the time it is sent to memory The user program deals with logical addresses; it never sees the real physical addresses o The concept of a logical address space that is bound to a separate physical address space is central to proper memory management
16 8.1 Background ⚫ Memory-Management Unit (MMU) ⚫ Hardware device that maps virtual address to physical address in the run-time ⚫ There are many different methods to accomplish such mapping ▪ In a simple MMU scheme, the value in the relocation register is added to every address generated by a user process (CPU) at the time it is sent to memory. ▪ The user program deals with logical addresses; it never sees the real physical addresses ⚫ The concept of a logical address space ⚫ that is bound to a separate physical address space ⚫ is central to proper memory management