Course contentsShow
← Computer Science
Lesson 1354 of 2,87231. Memory ManagementFree lesson

Address Translation in Paging

Learning how virtual addresses are split into page numbers and offsets, then translated to physical addresses.

Address Translation in Paging

What you'll learn: How the CPU translates a virtual address into a physical memory location using page numbers and offsets.

The Core Idea

When a program accesses memory, it uses a virtual address. The MMU must translate this into a physical address where the data actually lives. In paging, every virtual address is split into two parts:

  1. Page number (p) – identifies which page the address belongs to
  2. Page offset (d) – specifies the exact byte within that page

Think of it like a library: the page number tells you which bookshelf to visit, and the offset tells you exactly where on that shelf to look.

How Translation Works

Let's say we have:

  • Virtual address: 32 bits
  • Page size: 4 KB (4096 bytes = 2¹² bytes)

Step 1: Split the address

  • The lower 12 bits become the offset (since 2¹² = 4096)
  • The upper 20 bits become the page number

Step 2: Look up the page table

  • Use the page number as an index into the page table
  • The page table entry contains the frame number (where this page lives in physical RAM)

Step 3: Construct physical address

  • Combine the frame number with the original offset
  • Physical address = (frame number × page size) + offset

The offset stays the same because pages and frames are the same size. Only the "container" changes—from a virtual page to a physical frame.

Key Takeaway: Address translation splits a virtual address into page number and offset; the page table maps the page number to a physical frame number, which is then combined with the unchanged offset to form the physical address.