Site icon Entrepreneur Skill

The difference between logical and physical addresses in operating systems

The difference between logical and physical addresses in operating systems

An address uniquely identifies a location in memory. There are two types of addresses: logical addresses and physical addresses. A logical address is a virtual address and is visible to the user. Users cannot see the real address directly. Logical addresses are used to access physical addresses just like references. The fundamental difference between logical and physical addresses is that the CPU generates logical addresses during program execution whereas physical addresses refer to locations in memory devices.

There are several other differences between logical and physical addresses. Let’s discuss it with the help of the comparison chart shown below.

Comparison chart

basis for comparison logical address physical address
basic A virtual address is generated by the CPU. A physical address is a location within a memory unit.
address space The set of all logical addresses generated by the CPU with reference to the program is called the logical address space. The set of all physical addresses mapped to that logical address is called a physical address.
clock Users can see the logical address of the program. Users cannot see the program’s physical address.
access Users use logical addresses to access physical addresses. Users do not have direct access to physical addresses.
Generation Logical addresses are generated by the CPU. The physical address is calculated by the MMU.

 

Definition of the logical address

Addresses generated by the CPU while the program is running are called logical addresses. Logical addresses do not exist physically and are therefore virtual addresses. Therefore, it is also called a virtual address. This address is used as a reference to access the physical memory location. From a program point of view, the set of all generated logical addresses is called a logical address space.

Logical addresses are mapped to their physical addresses by a hardware device called a memory management unit. The address binding method used by the MMU generates identical logical and physical addresses during compile time and load time. However, during runtime, address binding methods generate different logical and physical addresses.

What is a physical address?

A physical address identifies a physical location in memory. The memory-management unit (MMU ) computes the physical address of that logical address. The MMU uses physical addresses to compute logical addresses. Users never deal with real addresses. Instead, the physical address is accessed by the user by its logical address. The user program generates a logical address and thinks that the program is running on this logical address. However, this program needs physical memory to run. So logical addresses must be mapped to physical addresses before they can be used.

Logical addresses are mapped to physical addresses using hardware called a memory management unit. In a logical address space, the set of all physical addresses that correspond to a logical address is called a physical address space.

Key Differences Between Logical and Physical Addresses in OS

  1. The basic difference between logical and physical addresses is that from the program’s point of view, the CPU generates logical addresses. On the other hand, a physical address is a location existing in a memory unit.
  2. The set of all logical addresses generated by the CPU for a program is called the logical address space. However, the set of all physical addresses mapped to that logical address is called the physical address space.
  3. Logical addresses do not physically exist in memory devices, so logical addresses are also called virtual addresses. A physical address is a location in a memory device that is physically accessible.
  4. The same logical and physical addresses are generated by compile-time and load-time address binding methods.
  5. Logical and physical addresses are generated while the runtime address binding methods are different.
  6. Logical addresses are generated by the CPU while the program is running, whereas physical addresses are computed by the Memory Management Unit (MMU).

conclusion:

A logical address is a reference used to access a physical address. Users can use this logical address to access the physical address of the memory device.

Exit mobile version