1. Introduction
When a program executes, it generates addresses to access memory. However, these addresses are not the actual physical locations in RAM.
This leads to a fundamental concept in operating systems:
Programs use logical addresses, while the hardware uses physical addresses.
The mapping between them is handled by the operating system and memory-management hardware.
Understanding the distinction between logical and physical addresses is essential because it forms the basis of memory protection, relocation, paging, segmentation, and virtual memory.
2. What is a Logical Address?
A logical address (also called a virtual address) is the address generated by the CPU during program execution.
The CPU always works with logical addresses rather than actual memory locations.
Key Characteristics
Generated by the CPU
Used by the executing program
Independent of physical memory layout
Exists in the logical address space
Requires translation before accessing memory
Example
Suppose a program generates:
Logical Address = 200
This does not necessarily mean memory location 200 in RAM.
Instead, it is an address within the process's logical address space.
3. What is a Physical Address?
A physical address is the actual location in main memory (RAM) where instructions and data are stored.
After address translation, the memory hardware accesses this physical address.
Key Characteristics
Used by memory hardware
Represents an actual RAM location
Exists in physical address space
Generated after address translation
Example
Physical Address = 1200
This represents a real memory location inside RAM.
4. Logical vs Physical Address (Core Idea)
The CPU does not directly generate physical addresses.
Instead, the following translation occurs:
Logical Address
↓
MMU
↓
Physical Address
The Memory Management Unit (MMU) performs this conversion.
This translation is essential for:
Process isolation
Memory protection
Relocation
Virtual memory
Efficient memory utilization
5. Visualization of Address Translation
CPU
↓
Generates Logical Address
↓
MMU Translation
↓
Physical Address
↓
RAM Access
Example:
Logical Address = 300
Base Register = 1000
Physical Address
= 1000 + 300
= 1300
Thus:
CPU sees → 300
RAM sees → 1300
6. Address Spaces
An address space is the range of addresses available for use.
Two address spaces are important in operating systems.
6.1 Logical Address Space
The logical address space is the set of all logical addresses generated by a process.
Every process views memory through its logical address space.
Example
0 → 1000
The process believes it owns memory locations within this range.
Characteristics
Visible to the process
Independent of actual memory
Can be larger than physical memory
Created by the operating system
6.2 Physical Address Space
The physical address space is the set of all actual memory addresses available in RAM.
Example
0 → 4096
These are the actual memory locations that exist in hardware.
Characteristics
Managed by hardware and OS
Represents real memory capacity
Shared among all processes
Key Insight
Logical and physical address spaces are generally different.
A process may see:
0 → 1000
while the corresponding physical locations may be:
5000 → 6000
The process is unaware of this mapping.
7. When Are Logical and Physical Addresses Equal?
Logical and physical addresses are equal only in very simple systems.
This occurs primarily in:
Compile-time binding
Early operating systems
Systems without address translation
Example:
Logical Address = 500
Physical Address = 500
No translation is required.
Modern Systems
Modern operating systems always use address translation.
Therefore:
Logical Address ≠ Physical Address
This separation provides flexibility and protection.
8. Role of MMU (Memory Management Unit)
The Memory Management Unit (MMU) is a hardware component responsible for translating logical addresses into physical addresses.
Without the MMU, execution-time address binding would not be possible.
Basic Translation Mechanism
The simplest MMU implementation uses a base register.
Formula:
Example
Logical Address = 300
Base Register = 1000
Translation:
Physical Address
= 1000 + 300
= 1300
Protection Mechanism
The MMU also performs protection checks.
It verifies:
Address is within valid range
Process is accessing only its own memory
Illegal memory access is prevented
If a process attempts to access memory outside its range, the MMU generates an exception.
9. Why Logical Addressing is Important
Logical addressing provides several important benefits.
9.1 Process Isolation
Each process operates in its own logical address space.
As a result:
Processes cannot directly access each other's memory
Errors remain isolated
System stability improves
9.2 Flexibility
Programs can execute regardless of their physical memory location.
The same program may run at:
1000
today and
5000
tomorrow without modification.
9.3 Security
Memory protection prevents unauthorized access.
A process cannot:
Read another process's memory
Modify kernel memory
Corrupt system data
9.4 Virtual Memory Support
Logical addressing enables virtual memory.
This allows:
Large programs to run
More processes to execute simultaneously
Memory usage beyond physical RAM
10. Real-World Analogy
Consider a hotel.
Logical Address
The room number assigned to a guest:
Room 205
Physical Address
The actual location of the room in the building.
The guest only needs the room number.
They do not need to know the exact architectural coordinates of the room.
Similarly:
Logical Address → Used by Program
Physical Address → Used by Hardware
The MMU acts like the hotel's directory system that maps room numbers to actual locations.
11. Key Differences
| Feature | Logical Address | Physical Address |
|---|---|---|
| Generated By | CPU | Memory Hardware |
| Visible To | Process | OS and Hardware |
| Address Space | Logical Address Space | Physical Address Space |
| Flexibility | High | Fixed |
| Translation Required | Yes | No |
| Usage | Program Execution | Actual Memory Access |
| Protection | Supported | Hardware Controlled |