Skip to main content

7.5 Address Translation Mechanics: Logical Address to Physical Address

📚Module 07: Main Memory ManagementTopic 7.5⏱️22 min read
🎯High-Yield For:Computer Science Foundations • Systems Engineering • Hardware Architecture

💡 Core Intuition​

🍳 The Everyday Analogy: The Postal Mail Forwarding Directory​

Imagine living in a global university with students scattered across dozens of off-campus residence halls:

Architecture Flow

The Campus Mail Routing Pipeline

Translating student directory IDs into physical dormitory room numbers

💡 Hover or click any card for deep-dive operational details
✉️Student ID

Logical Campus Address

Logical Address (p, d)

A letter arrives addressed to: Student #42, Line 15.

→
Consult Central Directory
📒Master Registry

Housing Office Directory

The Page Table

The mail clerk looks up Row 42 in the housing ledger.

→
Assemble Delivery Slip
🚪Physical Dorm

Real Room Delivery

Physical Address (f, d)

The mail carrier walks directly to Dormitory Hall #7, Room 15.

  • Logical Address: A coordinate generated by the CPU program counter: [Page Number p | Offset d].
  • Page Table Lookup: Translates the abstract Page Number pp into a concrete Physical Frame Number ff.
  • Physical Address: Direct coordinates on the motherboard's DRAM bus: [Frame Number f | Offset d]. The offset dd is untouched.

💻 Bridging to Computer Science​

Address translation is the hardware bridge connecting a process's illusion of a contiguous, private memory space to the fragmented physical reality of DRAM chips.


📚 Core Deep-Dive & Concepts​

1. Fundamental Mathematical Formulations​

To master address translation and solve numerical systems problems with 100% precision, we establish the canonical relationships between bit widths and storage capacities:

Address Space & Bit Width Relationship​

For any byte-addressable memory of capacity CC bytes:

Capacity C=2k bytes  ⟺  Address Bit Width k=log⁡2(C)\text{Capacity } C = 2^k \text{ bytes} \iff \text{Address Bit Width } k = \log_2(C)

Where:

  • 210 B=1 KB2^{10}\text{ B} = 1\text{ KB} (10 bits10\text{ bits})
  • 220 B=1 MB2^{20}\text{ B} = 1\text{ MB} (20 bits20\text{ bits})
  • 230 B=1 GB2^{30}\text{ B} = 1\text{ GB} (30 bits30\text{ bits})
  • 240 B=1 TB2^{40}\text{ B} = 1\text{ TB} (40 bits40\text{ bits})

Core Paging Dimensions​

Page Offset Bits (d)=log⁡2(Page Size)\text{Page Offset Bits } (d) = \log_2(\text{Page Size})

Total Pages in Logical Space =Logical Address Space (LAS)Page Size\text{Total Pages in Logical Space } = \frac{\text{Logical Address Space (LAS)}}{\text{Page Size}}

Page Number Bits (p)=log⁡2(Total Pages)=LAS Bits−d\text{Page Number Bits } (p) = \log_2(\text{Total Pages}) = \text{LAS Bits} - d

Total Frames in Physical Space =Physical Address Space (PAS)Frame Size\text{Total Frames in Physical Space } = \frac{\text{Physical Address Space (PAS)}}{\text{Frame Size}}

Frame Number Bits (f)=log⁡2(Total Frames)=PAS Bits−d\text{Frame Number Bits } (f) = \log_2(\text{Total Frames}) = \text{PAS Bits} - d

Logical Address Length =p+d\text{Logical Address Length } = p + d

Physical Address Length =f+d\text{Physical Address Length } = f + d

Page Table Size (PTS)=Total Pages×Page Table Entry (PTE) Size\text{Page Table Size (PTS)} = \text{Total Pages} \times \text{Page Table Entry (PTE) Size}


2. Comprehensive System Configurations: Worked Reference Table​

The following master reference table analyzes five fundamental systems architectures with varying Secondary Memory (Logical Address Space), Physical RAM (Physical Address Space), and Page Sizes:

System #Logical Space (SM)Physical RAM (MM)Page Size (PS)AddressabilityLA BitsPA BitsOffset Bits (dd)Page Bits (pp)Frame Bits (ff)
132 GB32\text{ GB}128 MB128\text{ MB}1 KB1\text{ KB}1 Byte35\mathbf{35}27\mathbf{27}10\mathbf{10}25\mathbf{25}17\mathbf{17}
24 TB4\text{ TB}8 GB8\text{ GB}2 KB2\text{ KB}1 Byte42\mathbf{42}33\mathbf{33}11\mathbf{11}31\mathbf{31}22\mathbf{22}
3512 GB512\text{ GB}2 GB2\text{ GB}512 B512\text{ B}1 Byte39\mathbf{39}31\mathbf{31}9\mathbf{9}30\mathbf{30}22\mathbf{22}
4128 GB128\text{ GB}32 GB32\text{ GB}128 B128\text{ B}1 Byte37\mathbf{37}35\mathbf{35}7\mathbf{7}30\mathbf{30}28\mathbf{28}
51 TB1\text{ TB}64 MB64\text{ MB}4096 B4096\text{ B} (4 KB4\text{ KB})1 Byte40\mathbf{40}26\mathbf{26}12\mathbf{12}28\mathbf{28}14\mathbf{14}

3. Step-by-Step Derivations of Classic Configurations​

Let us rigorously derive the exact values for each case from first principles:

Derivation for System 1​

  • Given:
    • Secondary Memory / Logical Space =32 GB=25×230 B=235 Bytes= 32\text{ GB} = 2^5 \times 2^{30}\text{ B} = 2^{35}\text{ Bytes}.
    • Main Memory / Physical Space =128 MB=27×220 B=227 Bytes= 128\text{ MB} = 2^7 \times 2^{20}\text{ B} = 2^{27}\text{ Bytes}.
    • Page Size =1 KB=210 Bytes= 1\text{ KB} = 2^{10}\text{ Bytes}.
    • Word Size =1 Byte= 1\text{ Byte} (Byte-addressable).
  • Step 1: Compute Offset Bits (dd): d=log⁡2(Page Size)=log⁡2(210)=10 bitsd = \log_2(\text{Page Size}) = \log_2(2^{10}) = \mathbf{10\text{ bits}}
  • Step 2: Compute Logical Address Bits (LA\text{LA}): LA=log⁡2(Logical Address Space)=log⁡2(235)=35 bits\text{LA} = \log_2(\text{Logical Address Space}) = \log_2(2^{35}) = \mathbf{35\text{ bits}} p=LA−d=35−10=25 bitsp = \text{LA} - d = 35 - 10 = \mathbf{25\text{ bits}}
  • Step 3: Compute Physical Address Bits (PA\text{PA}): PA=log⁡2(Physical Address Space)=log⁡2(227)=27 bits\text{PA} = \log_2(\text{Physical Address Space}) = \log_2(2^{27}) = \mathbf{27\text{ bits}} f=PA−d=27−10=17 bitsf = \text{PA} - d = 27 - 10 = \mathbf{17\text{ bits}}
  • Verification:
    • Total Pages =225=33,554,432= 2^{25} = 33,554,432 pages.
    • Total Frames =217=131,072= 2^{17} = 131,072 frames.

Derivation for System 2​

  • Given:
    • LAS=4 TB=22×240 B=242 Bytes  ⟹  LA=42 bits\text{LAS} = 4\text{ TB} = 2^2 \times 2^{40}\text{ B} = 2^{42}\text{ Bytes} \implies \mathbf{\text{LA} = 42\text{ bits}}.
    • PAS=8 GB=23×230 B=233 Bytes  ⟹  PA=33 bits\text{PAS} = 8\text{ GB} = 2^3 \times 2^{30}\text{ B} = 2^{33}\text{ Bytes} \implies \mathbf{\text{PA} = 33\text{ bits}}.
    • Page Size=2 KB=21×210 B=211 Bytes  ⟹  d=11 bits\text{Page Size} = 2\text{ KB} = 2^1 \times 2^{10}\text{ B} = 2^{11}\text{ Bytes} \implies \mathbf{d = 11\text{ bits}}.
  • Address Breakdown: p=LA−d=42−11=31 bitsp = \text{LA} - d = 42 - 11 = \mathbf{31\text{ bits}} f=PA−d=33−11=22 bitsf = \text{PA} - d = 33 - 11 = \mathbf{22\text{ bits}}

4. Page Table Entry (PTE) Sizing & Memory Footprint​

A common source of confusion in computer systems is the distinction between Frame Number Bits and Page Table Entry Size:

Minimum Page Table Entry (PTE) Sizing Rule

A Page Table Entry must store the Frame Number (f bitsf\text{ bits}) plus any hardware status bits. Because memory is byte-addressable, data structures cannot allocate fractional bytes:

PTE Size (minimum)=⌈f+Status Bits8⌉ Bytes\mathbf{\text{PTE Size (minimum)} = \left\lceil \frac{f + \text{Status Bits}}{8} \right\rceil \text{ Bytes}}

If status bits are not explicitly specified in problem statements, assume PTE Size=⌈f/8⌉ Bytes\text{PTE Size} = \lceil f / 8 \rceil\text{ Bytes}.

Detailed Example: Sizing the Page Table​

  • Given:
    • Virtual Address Space =16 GB=234 Bytes  ⟹  LA=34 bits= 16\text{ GB} = 2^{34}\text{ Bytes} \implies \text{LA} = 34\text{ bits}.
    • Physical RAM =64 MB=226 Bytes  ⟹  PA=26 bits= 64\text{ MB} = 2^{26}\text{ Bytes} \implies \text{PA} = 26\text{ bits}.
    • Page Size =1 KB=210 Bytes  ⟹  d=10 bits= 1\text{ KB} = 2^{10}\text{ Bytes} \implies d = 10\text{ bits}.
  • Calculate Bits:
    • Page number bits p=34−10=24 bitsp = 34 - 10 = 24\text{ bits}.
    • Total Pages =224=16 Million pages= 2^{24} = 16\text{ Million pages}.
    • Frame number bits f=26−10=16 bitsf = 26 - 10 = 16\text{ bits}.
  • Minimum PTE Size:
    • To store 1616 bits of frame number, we require: PTE Size=16 bits8 bits/byte=2 Bytes\text{PTE Size} = \frac{16\text{ bits}}{8\text{ bits/byte}} = \mathbf{2\text{ Bytes}}
  • Total Page Table Size: Page Table Size=Total Pages×PTE Size=224×2 Bytes=225 Bytes=32 MB\text{Page Table Size} = \text{Total Pages} \times \text{PTE Size} = 2^{24} \times 2\text{ Bytes} = 2^{25}\text{ Bytes} = \mathbf{32\text{ MB}}
  • Architectural Insight:
    • Notice that the physical memory is only 64 MB64\text{ MB}!
    • Storing a single process's page table consumes 32 MB32\text{ MB}, which is 50%50\% of the entire physical RAM!
    • This demonstrates why naive single-level paging collapses on large virtual address spaces and necessitates Multi-Level Paging.

🏭 In The Real World: Production Case Study​

x86-64 4-Level Paging (Paging-48 & Paging-57)​

Modern Intel and AMD server processors do not utilize 64 full bits of virtual address space because managing 2642^{64} bytes would require astronomically large page tables:

Address BitfieldBit RangeWidthPurpose in Multi-Level Paging Hierarchy
Sign ExtensionBits 63…4863\dots4816 bits16\text{ bits}Canonical form check (Must be all 0s for user space or all 1s for kernel)
PML4 IndexBits 47…3947\dots399 bits9\text{ bits}Level 4: Page Map Level 4 Table (512512 entries)
PDPT IndexBits 38…3038\dots309 bits9\text{ bits}Level 3: Page Directory Pointer Table (512512 entries)
PD IndexBits 29…2129\dots219 bits9\text{ bits}Level 2: Page Directory (512512 entries)
PT IndexBits 20…1220\dots129 bits9\text{ bits}Level 1: Page Table (512512 entries)
Page OffsetBits 11…011\dots012 bits12\text{ bits}Byte displacement within target 4 KB4\text{ KB} physical frame
  1. Canonical 48-Bit Virtual Addressing:
    • Bits 00 to 1111 (1212 bits) specify the offset inside a standard 4 KB4\text{ KB} page (212=4096 bytes2^{12} = 4096\text{ bytes}).
    • The remaining 3636 bits are divided into four 9-bit chunks (9+9+9+9=369 + 9 + 9 + 9 = 36).
    • Why 9 bits? Because each level's table has 29=5122^9 = 512 entries. With an 8-byte (64-bit) PTE, 512×8 B=4096 bytes=4 KB512 \times 8\text{ B} = 4096\text{ bytes} = 4\text{ KB}—meaning every page table fits inside a physical frame!
  2. 5-Level Paging (PML5):
    • Modern Linux kernels powering AI clusters support 57-bit virtual addressing by adding a 5th level (PML5) to address up to 128 PB128\text{ PB} (petabytes) of virtual memory and 4 PB4\text{ PB} of physical DRAM.

🎯 Exam & Interview Pitfall Check​

Core Conceptual Questions

Question 1: In a computer system, the logical address is 3232 bits and the physical address is 2424 bits. The page size is 4 KB4\text{ KB}.

  1. Find the number of pages in the logical address space.
  2. Find the number of frames in physical memory.
  3. If each page table entry takes 44 bytes, calculate the total size of the page table for a process.

Answer:

  1. Number of pages:
    • Page Size=4 KB=212 bytes  ⟹  d=12 bits\text{Page Size} = 4\text{ KB} = 2^{12}\text{ bytes} \implies d = 12\text{ bits}.
    • Logical address length =32 bits  ⟹  p=32−12=20 bits= 32\text{ bits} \implies p = 32 - 12 = 20\text{ bits}.
    • Number of pages =220=1,048,576 pages= 2^{20} = \mathbf{1,048,576\text{ pages}} (1 Million pages1\text{ Million pages}).
  2. Number of frames:
    • Physical address length =24 bits  ⟹  f=24−12=12 bits= 24\text{ bits} \implies f = 24 - 12 = 12\text{ bits}.
    • Number of frames =212=4096 frames= 2^{12} = \mathbf{4096\text{ frames}}.
  3. Total size of Page Table:
    • Size=Number of pages×PTE Size=220×4 bytes=4×220 bytes=4 MB\text{Size} = \text{Number of pages} \times \text{PTE Size} = 2^{20} \times 4\text{ bytes} = 4 \times 2^{20}\text{ bytes} = \mathbf{4\text{ MB}}.

Question 2: A byte-addressable system has a physical address space of 512 MB512\text{ MB} and a page size of 8 KB8\text{ KB}. What is the minimum number of bits required to store the physical frame number in each page table entry? Answer:

  1. Physical Address Space=512 MB=29×220 bytes=229 bytes  ⟹  PA=29 bits\text{Physical Address Space} = 512\text{ MB} = 2^9 \times 2^{20}\text{ bytes} = 2^{29}\text{ bytes} \implies \text{PA} = 29\text{ bits}.
  2. Page Size=8 KB=23×210 bytes=213 bytes  ⟹  d=13 bits\text{Page Size} = 8\text{ KB} = 2^3 \times 2^{10}\text{ bytes} = 2^{13}\text{ bytes} \implies d = 13\text{ bits}.
  3. Frame Number Bits f=PA−d=29−13=16 bits\text{Frame Number Bits } f = \text{PA} - d = 29 - 13 = \mathbf{16\text{ bits}}.
  4. Conclusion: At minimum, 1616 bits must be dedicated strictly to hold the frame number.
Common Interview Traps
  • The Word-Addressable Trap: Always verify whether the problem specifies byte-addressable or word-addressable memory. If a system is 2-byte word addressable, 4 KB4\text{ KB} represents 2 K words2\text{ K words}, meaning d=11d = 11 bits instead of 1212 bits!
  • The Frame Number vs Physical Address Confusion: Students often mistake ff (frame number) for the full physical address. Remember: Physical Address=[f∣d]\text{Physical Address} = [f \mid d]. The frame number is only the higher-order component.
  • Rounding Up PTE Sizes: In theoretical questions, if f=17f = 17 bits, the minimal byte-aligned storage is ⌈17/8⌉=3\lceil 17/8 \rceil = 3 bytes. In real systems, hardware alignments favor power-of-two bytes (44 bytes or 88 bytes). Always state your alignment assumption clearly.

💬

Discussion & Doubts