Logical vs Physical Address Space

A logical address (also called a virtual address) is the address a running program sees, generated by the CPU relative to the process's own private view of memory, while a physical address is the actual location of the data in RAM. The Memory Management Unit (MMU) translates logical addresses into physical addresses as the program runs.

5 min read

Every running program works with addresses, but the address a program sees is not the same as the actual physical location in RAM where that data lives. Understanding the difference between these two address spaces is the foundation for everything else in memory management (paging, segmentation, virtual memory) that builds on top of it.

Logical vs physical address: differences table

BasisLogical addressPhysical address
Also calledVirtual addressReal address
Generated byThe CPU, while the program runsThe MMU, from the logical address
Seen by the programYes, the program uses only logical addressesNo, the program never sees it
Address spaceLogical address space: every logical address a program generatesPhysical address space: the RAM addresses those map to
Range with a relocation register R0 to maxR + 0 to R + max
When the process moves in RAMStays the sameChanges
Mapping managed byThe OS sets it up (base register or page tables)The MMU applies it on every access

The two are the same number when addresses are bound at compile time or load time, and differ when they are bound at execution time, which is how every modern OS works.

What each one actually is

A logical address (also called a virtual address) is generated by the CPU while a program runs, relative to that program's own private view of memory. Every process gets to act as if it has its own private range of addresses starting from zero, completely independent of what any other process is doing.

A physical address is the real location in the computer's actual RAM hardware. This is where the data genuinely lives, and it's shared across every process running on the machine.

The Memory Management Unit (MMU), a piece of hardware built into the CPU, translates every logical address a program generates into the correct physical address before the memory access actually happens. The program itself never needs to know or care what the real physical address is.

Why this separation exists

If programs worked directly with physical addresses, every program would need to know exactly where in RAM every other program was loaded, and two programs could never safely both think they own the same address (say, address 1000) without colliding. By giving every process its own private logical address space and translating behind the scenes, the OS can load multiple programs into memory simultaneously, move them around in physical RAM without the program noticing, and prevent one process's memory accesses from ever touching another process's actual data.

A worked example

Suppose a process's logical address space runs from 0 to 4095 (a 4KB range, purely from that process's own point of view). The OS has actually loaded this process starting at physical address 8192 in real RAM.

If the program executes an instruction referencing logical address 100, the MMU translates it: physical address = base (8192) + logical address (100) = 8292. The program only ever "sees" and works with 100; the MMU's translation to 8292 is invisible to it.

If the OS later needs to move this process to a different area of physical RAM (say, starting at 16384 instead), it only has to update the base value the MMU uses. Every logical address the program generates still works exactly the same, translating to a different but correct new physical location, with zero changes needed in the program itself.

Compile time, load time and execution time binding

A program's addresses can be bound to physical memory at three points:

  • Compile time: if the final memory location is known when the program is compiled, the compiler emits physical addresses directly. Logical and physical addresses are identical, and the program must be recompiled to run anywhere else.
  • Load time: the compiler emits relocatable code and the loader fixes the real addresses when the program is loaded. Logical and physical addresses are again identical, and moving the program means reloading it.
  • Execution time: addresses are translated by the MMU on every access, so the process can be moved in memory while it runs. Only here do logical and physical addresses differ, and this is what Linux, Windows and macOS use.

Where this matters in real systems

This logical/physical split is precisely what makes multitasking safe. Without it, a single buggy or malicious program could read or overwrite another program's real memory directly. Every modern general-purpose OS (Linux, Windows, macOS) relies on hardware-enforced address translation for exactly this reason, it's a foundational security and stability boundary, not just a convenience.

What interviewers actually ask about logical vs physical addresses

  • "What is the difference between a logical and a physical address?" A logical address is generated by the CPU relative to a process's own private view of memory; a physical address is the actual location in real RAM. The MMU translates between them.
  • "What component performs the translation?" The Memory Management Unit (MMU), a hardware component.
  • "Why do processes use logical addresses instead of physical addresses directly?" So multiple processes can each act as if they own their own private memory space starting at zero, without colliding with each other or needing to know real physical locations, and so the OS can safely relocate a process in physical memory without the process needing to change anything.
  • "What happens if a process tries to access a logical address outside its allowed range?" The MMU (with OS support) detects this and raises a protection fault, preventing the process from touching memory it doesn't own.

Key takeaways

  • Logical addresses are what a running program sees; physical addresses are real RAM locations.
  • The MMU translates logical addresses to physical addresses at runtime, transparently to the program.
  • This separation lets the OS run multiple processes safely and relocate them in physical memory without the program noticing.
  • It's also the basis for memory protection between processes.
All 205 OS interview questions

Browse all Operating Systems topics

Log in to save which topics you've read across every subject.

Frequently asked questions

What is the difference between a logical and a physical address?

A logical address is generated by the CPU relative to a process's own private view of memory; a physical address is the actual location in real RAM. The MMU translates between them.

What component performs the translation?

The Memory Management Unit (MMU), a hardware component.

Why do processes use logical addresses instead of physical addresses directly?

So multiple processes can each act as if they own their own private memory space starting at zero, without colliding with each other or needing to know real physical locations, and so the OS can safely relocate a process in physical memory without the process needing to change anything.

What happens if a process tries to access a logical address outside its allowed range?

The MMU (with OS support) detects this and raises a protection fault, preventing the process from touching memory it doesn't own.