The key difference between logical address and physical address is that CPU generates logical address during program execution whereas the physical address is a location in the memory unit.
In simple terms, CPU generates the logical address or virtual address. From the perspective of a program that is running, an item seems to be located at the address provided by the logical address. Memory unit observes the physical address. Moreover, it allows accessing a particular memory cell in the main memory by the data bus.
CONTENTS
1. Overview and Key Difference
2. What is Logical Address
3. What is Physical Address
4. Side by Side Comparison – Logical Address vs Physical Address in Tabular Form
5. Summary
What is Logical Address?
CPU generates logical address. From the perspective of a program that is running, an item seems to be located at the address provided by the logical address. Application programs that are running on the computer do not see the physical addresses. They always work using the logical addresses. The logical address space is the set of logical addresses, a program generates. It is necessary to map the logical addresses to physical addresses before using them. The hardware device Memory Management Unit (MMU) handles this mapping process.
MMU Mapping Schemes
MMU follows several mapping schemes. In the simplest mapping scheme, the value in the relocation register is added to each logical address produced by application programs before sending them to the memory. There are also some other complex methods to generate the mapping. Address binding (i.e. allocating instructions and data into memory addresses) can happen at three different times.
Firstly, it can happen in compile time if the actual memory locations are known in advance, and this would generate the absolute code in compile time. It can also happen at load time if the memory locations are not known in advance. For this, re-locatable code needs to be generated at compile time. Furthermore, address binding can happen at execution time. This requires hardware support for address mapping. In compile time and load time address binding, logical and physical addresses are the same. But this procedure is different when address binding happens in execution time.
What is Physical Address?
Memory unit observes the physical address or the real address. It allows the data bus to access a particular memory cell in the main memory. MMU maps the logical address to physical address. For example, using the simplest mapping scheme, which adds the relocation register (assume that the value in the register is y) value to the logical address, a logical address ranges from 0 to x would map to a physical address range y to x+y.
Furthermore, this is also called the physical address space of that program. All the logical addresses need to be mapped into physical addresses before they can be used.
What is the Difference Between Logical Address and Physical Address?
Logical Address vs Physical Address |
|
Logical address is the address at which an item appears to reside from the perspective of an executing application program. | Physical address is a memory address that is represented in the form of a binary number on the address bus circuitry in order to enable the data bus to access a particular storage cell of main memory, or a register of memory mapped I/O device. |
Visibility | |
The user can view the logical address of a program. | The user can not view physical address of program. |
Method of Generation | |
CPU generates the logical address. | MMU computes the Physical address. |
Accessibility | |
The user can use the logical address to access the physical address. | The user can not directly access physical address. |
Summary – Logical Address vs Physical Address
The difference between logical address and physical address is that CPU generates logical address when program executes whereas the physical address is a location in the memory unit. All the logical addresses need to be mapped into physical addresses before the MMU can use them. Physical and logical addresses are same when using compile time and load time address binding, but they differ when using execution time address binding.
Reference:
1.“Logical Address.” Wikipedia, Wikimedia Foundation, 30 Apr. 2018. Available here
2.“Physical Address.” Wikipedia, Wikimedia Foundation, 30 Apr. 2018. Available here
Image Courtesy:
1.’MMU principle’By Andre Schieleit – Own work, (Public Domain) via Commons Wikimedia
Sophiya Raj says
good ans
Galib says
good answere
vincent says
good answer with best and clear explanation.