liveBook · Manning

MMU

As explained in Rust in Action: Systems programming concepts and techniques

A memory management unit is processor hardware that translates virtual addresses into physical addresses and enforces memory-access attributes.

A program accesses memory through virtual addresses, not physical addresses in RAM. The memory management unit (MMU) is CPU hardware that translates those addresses. The operating system maintains a page table containing the translation information; the CPU performs the translation when the program accesses memory. section 6.4.1 section 6.4.3

Two details make that translation practical:

  • Virtual memory is divided into pages, typically 4 KB each. Mapping blocks avoids storing a separate translation for every variable. section 6.4.3
  • The CPU caches recent translations in a translation lookaside buffer (TLB). Without a cached translation, a memory access can require an additional memory lookup. section 6.4.3

Following a memory access

Imagine a program repeatedly accessing data on the same virtual-memory page. The first access may need translation information from memory; later accesses can benefit from a cached translation. This is one reason lean data structures can perform better than deeply nested ones: reaching the TLB’s capacity can be costly. section 6.4.3

This is a general model, not a rule for every machine. Operating systems and CPUs differ in how they cooperate, and some constrained systems, such as microcontrollers, use real addressing instead. section 6.4.3

How Rust in Action: Systems programming concepts and techniques covers it

How deep it goes
Defines the MMU and explains pages, page tables, lookup costs, and TLB caching without detailing translation-system internals.
Examples
Uses a potential extra memory lookup and the cost of reaching TLB capacity to illustrate performance consequences.
What it assumes
Introduces virtual memory, real memory, page tables, and the MMU while assuming only that a running program accesses memory.
What you can do after
Evaluate/understand why virtual-memory access requires translation and why data-structure layout can affect translation-cache performance.
How it connects
Connects the MMU to virtual memory, physical memory, page tables, pages, the operating system, and the TLB.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust in Action: Systems programming concepts and techniques. The section links point to the parts of the book it draws on.