Main Memory: Allocation, Linking & Segmentation

the memory management unit

/ MMU = "em-em-yoo" /

Imagine a fast, tireless translator standing between someone who speaks only 'program language' and a warehouse clerk who speaks only 'real-shelf-number language'. Every time the program says 'fetch item 1000', the translator instantly converts it to the real shelf and passes it on, and slaps the program's hand if it asks for a shelf it is not allowed to touch. The memory management unit (MMU) is that translator, built into the CPU as hardware.

Concretely, the MMU sits between the CPU and memory and performs the logical-to-physical translation on every single memory access, at hardware speed, while the program runs. In the simplest design it holds a base (relocation) register and a limit register: it checks that the logical address is below the limit (otherwise it traps as an illegal access) and then adds the base to produce the physical address. In a paging system the MMU instead splits the address into a page number and offset and looks the page up in a page table. Either way, the program only ever generates logical addresses; the MMU is what makes them real.

Why it matters: without the MMU, execution-time address binding would be impossibly slow — the OS would have to translate every reference in software. The MMU is also where memory protection lives: because it checks bounds on every access, a process physically cannot reach outside its allotted region, which is what keeps a buggy or malicious program from corrupting others. It is the hardware foundation that makes safe multiprogramming practical.

The MMU holds base = 90000 and limit = 5000. The program issues logical address 1200: since 1200 is below 5000, the MMU outputs physical 91200. If the program issues 6000, the MMU sees 6000 is at or above 5000 and traps to the OS instead of touching memory.

Translate and bounds-check on every access — at hardware speed.

The MMU works on logical-to-physical translation only; it is not the cache. And its protection is only as good as the limit/page-table values the OS loads — the OS must set them correctly on every context switch.

Also called
MMU記憶體管理單元