In operating systems, logical and physical addresses are used to manage and access memory. Here’s an overview of each:
Logical address: A logical address, also known as a virtual address, is an address generated by the CPU during program execution. It is the address seen by the process and is relative to the program’s address space. The process accesses memory using logical addresses, which are translated by the operating system into physical addresses.
Physical address: A physical address is the actual address in main memory where data is stored. It is a location in physical memory, as opposed to a virtual address. Physical addresses are used by the memory management unit (MMU) to translate logical addresses into physical addresses.
The translation from logical to physical addresses is performed by the operating system’s memory management unit. The MMU uses a page table to translate logical addresses into physical addresses. The page table maps each logical page number to a physical frame number.
The similarity between logical and physical addresses in the operating system are listed below:
- Both logical and physical addresses are used to identify a specific location in memory.
- Both logical and physical addresses can be represented in different formats, such as binary, hexadecimal, or decimal.
- Both logical and physical addresses have a finite range, which is determined by the number of bits used to represent them.
Here are some important points about logical and physical addresses in operating systems:
The use of logical addresses provides a layer of abstraction that allows processes to access memory without knowing the physical memory location.
Logical addresses are mapped to physical addresses using a page table. The page table contains information about the mapping between logical and physical addresses.
The MMU translates logical addresses into physical addresses using the page table. This translation is transparent to the process and is performed by hardware.
The use of logical and physical addresses allows the operating system to manage memory more efficiently by using techniques such as paging and segmentation.
Some reference books on operating system concepts that cover logical and physical addressing include:
“Operating System Concepts” by Abraham Silberschatz, Peter Baer Galvin, and Greg Gagne.
“Modern Operating Systems” by Andrew S. Tanenbaum.
“Operating Systems: Three Easy Pieces” by Remzi H. Arpaci-Dusseau and Andrea C. Arpaci-Dusseau.
These books provide detailed coverage of operating system concepts, including memory management and addressing techniques.
Logical Address is generated by CPU while a program is running. The logical address is virtual address as it does not exist physically, therefore, it is also known as Virtual Address. This address is used as a reference to access the physical memory location by CPU. The term Logical Address Space is used for the set of all logical addresses generated by a program’s perspective.
The hardware device called Memory-Management Unit is used for mapping logical address to its corresponding physical address.
Physical Address identifies a physical location of required data in a memory. The user never directly deals with the physical address but can access by its corresponding logical address. The user program generates the logical address and thinks that the program is running in this logical address but the program needs physical memory for its execution, therefore, the logical address must be mapped to the physical address by MMU before they are used. The term Physical Address Space is used for all physical addresses corresponding to the logical addresses in a Logical address space.
Mapping virtual-address to physical-addresses
Differences Between Logical and Physical Address in Operating System
- The basic difference between Logical and physical address is that Logical address is generated by CPU in perspective of a program whereas the physical address is a location that exists in the memory unit.
- Logical Address Space is the set of all logical addresses generated by CPU for a program whereas the set of all physical address mapped to corresponding logical addresses is called Physical Address Space.
- The logical address does not exist physically in the memory whereas physical address is a location in the memory that can be accessed physically.
- Identical logical addresses are generated by Compile-time and Load time address binding methods whereas they differs from each other in run-time address binding method. Please refer this for details.
- The logical address is generated by the CPU while the program is running whereas the physical address is computed by the Memory Management Unit (MMU).
||generated by CPU
||location in a memory unit
||Logical Address Space is set of all logical addresses generated by CPU in reference to a program.
||Physical Address is set of all physical addresses mapped to the corresponding logical addresses.
||User can view the logical address of a program.
||User can never view physical address of program.
||generated by the CPU
||Computed by MMU
||The user can use the logical address to access the physical address.
||The user can indirectly access physical address but not directly.
||Logical address can be change.
||Physical address will not change.
Unlock the Power of Placement Preparation!
Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation
Course is the ultimate guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation