Physical vs Logical Addresses
What You'll Learn
You'll understand the crucial distinction between the addresses your programs use and the actual hardware memory locations where data lives.
Why Two Types of Addresses?
When a program runs, it references memory using logical addresses (also called virtual addresses)—these are the addresses your code "thinks" it's using. However, the CPU's memory hardware actually stores data at physical addresses—the real locations in RAM chips.
Think of it like mail delivery: you write a friend's name on an envelope (logical address), but the postal system needs their street address (physical address) to actually deliver it. The mapping between them happens behind the scenes.
The Key Distinction
Logical addresses are:
- Generated by the CPU during program execution
- What your program variables and pointers contain
- Independent of where the program is physically loaded
- Typically start from 0 for each process
Physical addresses are:
- Actual locations in physical RAM
- What the memory hardware uses
- Managed by the operating system and memory management unit (MMU)
- Unique across the entire system
Why This Matters
This separation allows the OS to:
- Load programs anywhere in physical memory without modifying their code
- Run multiple programs simultaneously without address conflicts
- Implement protection so processes can't access each other's memory
- Enable features like virtual memory and swapping
The Memory Management Unit (MMU) is the hardware component that translates logical addresses to physical addresses on-the-fly, transparently to your program.
Key Takeaway: Logical addresses are the "language" programs speak; physical addresses are where data actually resides in hardware—the OS and MMU bridge this gap, enabling flexible, safe memory management.