← back to hub

mmu & virtual memory

1. The Grand Illusion & Security

Every process thinks it owns the entire computer.

  • Compilers assume memory is a clean, infinite, contiguous block. This is Virtual Memory.
  • Security: By keeping processes in their own Virtual spaces, they are completely isolated. Process A cannot accidentally read Process B's data because their virtual addresses map to completely different physical locations.

2. Pages and Frames

We don't translate memory byte-by-byte; we move it in chunks.

  • The OS chops Virtual Memory into blocks called Pages (e.g., 4KB).
  • Physical RAM is chopped into matching blocks called Frames.
  • This solves fragmentation! A process can have contiguous Virtual Pages that map to completely scattered, non-contiguous Physical Frames.

3. The Unchanging Offset

The MMU only translates the Page Number. The Offset stays identical.

  • When the CPU asks for Virtual Address 0x2A4F, the Memory Management Unit (MMU) splits it.
  • 2 is the Page Number (VPN). A4F is the Offset (the exact byte inside that 4KB page block).
  • The MMU looks up Page 2 in the Page Table. If it maps to Physical Frame 5, the true physical address becomes 0x5A4F. Notice how the A4F never changed!
Virtual Memory (App)
Clean, Sequential Pages
MMU & Page Table
Hardware Routing Table
VPNValidPFN
Awaiting CPU Request...
Physical RAM (HW)
Fragmented Frames
OS Kernel & MMU Logs