Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 94 of 9361. Foundations of Digital Logic and Computer ArchitectureFree lesson

Translating Virtual Addresses to Physical Memory

Map virtual memory addresses to physical locations using page tables to support process isolation and efficient memory management in modern systems.

In this lesson, you will learn how the CPU bridges the gap between the memory addresses a program "sees" and the actual storage locations in hardware using page tables.

The Illusion of Virtual Memory

When you write code, you use pointers that seem to point to specific memory locations. However, these are virtual addresses. In a modern system, your program doesn't "own" the entire physical RAM. Instead, the operating system gives each process a private, isolated virtual address space. This ensures that Process A cannot accidentally overwrite the memory used by Process B.

To make this work, the hardware must translate that virtual address into a physical address that points to an actual cell in your RAM chips.

The Role of the Page Table

Think of memory as being divided into fixed-size chunks called pages. The translation process uses a data structure stored in memory called a Page Table.

When the CPU needs to access an address, it performs a lookup:

  1. Virtual Address: The CPU splits the address into two parts: the Page Number and the Offset (the specific byte within that page).
  2. Page Table Lookup: The CPU uses the Page Number as an index into the Page Table.
  3. Physical Address: The entry in the table gives the Physical Frame Number. The CPU combines this frame number with the original offset to form the final Physical Address.

Imagine a simplified 16-bit system where we map a 4-bit Page Number to a 4-bit Physical Frame:

// Simplified Logic
Virtual Address: [ Page Number (4 bits) | Offset (12 bits) ]
Page Table Lookup: Page Number -> Physical Frame Number
Physical Address: [ Frame Number (4 bits) | Offset (12 bits) ]

If the Page Table says a virtual page is "invalid" or "not present," the hardware triggers an exception (a Page Fault), allowing the operating system to load the necessary data from the disk into RAM. This abstraction is what allows your system to run many complex programs simultaneously without them interfering with one another, while also giving the OS the flexibility to move data around in physical memory without the program ever knowing.

Key Takeaway: Virtual memory uses page tables to map virtual addresses to physical locations, providing the process isolation and memory management necessary for modern computing.