Signup/Sign In

Logical and Physical Address Space in Operating Systems

In this tutorial, we will be covering the concept of logical and physical address space.

The address that is generated by the CPU is commonly referred to as the Logical Address. It is basically a virtual address. The logical address is basically the address of an instruction or data used by any program.

The set of all logical addresses that are generated by any program is referred to as Logical Address Space.

The address that is loaded into the memory-address register of the memory is commonly referred to as a Physical address. A physical address cannot be accessed by the user directly but the user can calculate the physical address with the help of a Logical address.

The user's program mainly generates the logical address and the user thinks that the program is running in this logical address but the program mainly needs physical memory in order to complete its execution.

The set of all physical addresses corresponding to the Logical addresses is commonly known as Physical Address Space.

Memory Management Unit(MMU) in OS

It is a hardware device that does the run-time mapping from the virtual address to the physical address. It is located within the Central Processing Unit.

Let us understand the concept of mapping with the help of a simple MMU scheme and that is a base-register scheme.

In the above diagram, the base register is termed the Relocation register. The relocation register is a special register in the CPU and is used for the mapping of logical addresses used by a program to physical addresses of the system's main memory.

The value in the relocation register is added to every address that is generated by the user process at the time when the address is sent to the memory.

MMU Example

Suppose the base is at 14000, then an attempt by the user to address location 0 is relocated dynamically to 14000; thus access to location 356 is mapped to 14356.

It is important to note that the user program never sees the real physical addresses. The Program can create a pointer to location 356 and store it in the memory and then manipulate it after that compare it with other addresses as number 356.

User program always deals with the logical addresses. The Memory Mapping unit mainly converts the logical addresses into the physical addresses. The final location of the referenced memory address is not determined until the reference is made.

There are two types of addresses that we have:

logical addresses(lies in the range 0 to max).

physical addresses(lies in the range R+0 to R+max for the base value R)

As we have told you above the user generates only a logical address and then thinks that the process runs in locations 0 to max. However, these logical addresses must be mapped to physical addresses before they are used.

Difference Between Logical Address and Physical Address

Let us now cover the differences between the Logical addresses and Physical addresses in the Operating System

S.No Logical Address Physical Address
1. Users can access the logical address of the Program. User can never access the physical address of the Program
2. The logical address is generated by the CPU. The physical address is located in the memory unit.
3. The user can access the physical address with the help of a logical address. A physical address can be accessed by a user indirectly b ut not directly.
4.

The logical address does not exist physically in the memory and thus termed as a Virtual address.

On the other hand, the physical address is a location in the memory. Thus it can be accessed physically.
5. The set of all logical addresses that are generated by any program is referred to as Logical Address Space. The set of all physical addresses corresponding to the Logical addresses is commonly known as Physical Address Space.
6. This address is generated by the CPU. It is computed by the Memory Management Unit(MMU).



About the author:
Aspiring Software developer working as a content writer. I like computer related subjects like Computer Networks, Operating system, CAO, Database, and I am also learning Python.