You are watching: What is the difference between a physical address and a virtual address?
The physical address refers to a location in the memory. It allows access to data in the main memory. A physical address is not directly accessible to the user program hence, a logical address needs to be mapped to it to make the address accessible. This mapping is done by the MMU. Memory Management Unit(MMU) is a hardware component responsible for translating a logical address to a physical address.Logical Address
A logical address or virtual address is an address that is generated by the CPU during program execution. A logical address doesn't exist physically. The logical address is used as a reference to access the physical address. A logical address usually ranges from zero to maximum (max). The user program that generates the logical address assumes that the process runs on locations between 0 to the max. This logical address(generated by CPU) combines with the base address generated by the MMU to form the physical address.
The diagram below explains how the mapping between logical and physical addresses is done.
The CPU generates the logical address(here, 324).The MMU will generate the base address (here, 2000) which is stored in the Relocation Register.The value of Relocation Register(here, 2000) is added to the logical address to get the physical address. i.e. 2000+324= 2324(Physical Address).Difference between the physical and logical address The fundamental difference between a physical address and the logical address is that logical address is generated by the CPU while the program is running whereas the physical address is a location in memory.The logical address is generated by the CPU whereas physical address is computed by the MMU.The logical address does not exist physically in the memory hence it is sometimes known as virtual address whereas the physical address is a location in the memory unit.The logical address is used as a reference to access the physical address. The physical address cannot be accessed directly.Users can view the logical address of a program. But, they cannot view the physical address of a program.The set of all the logical addresses generated in reference to a program by the CPU is called Logical Address Space whereas the set of all the physical addresses mapped to the logical address is called Physical Address Space.
This was about the differences between logical and physical addresses. Hope you learned something new today.
See more: The Proud Family Don T Leave Home Without It, Don'T Leave Home Without It
Do share this blog with your friends to spread the knowledge. Visit our YouTube channel for more content. You can read more blogs from here.