Operating Systems · Module 6 — Memory Management
Logical and physical addresses, and the MMU
The memory management unit is a piece of hardware that sits between the CPU and the memory bus. Every address the CPU produces passes through it and comes out translated.
Sign in to track your score
The compile job reads from address 5000.
The browser reads from address 5000 at almost the same moment.
They are different programs with different data. Neither can see the other's memory — Module 2 promised that. Yet both used the same number.
Somebody is lying to at least one of them.
Why & what
Two kinds of address.
- A logical address is what the program uses. Also called a virtual address. Every process starts counting from 0, so every process has an address 5000.
- A physical address is a real location in the 8 GB of RAM. There is only one address 5000 in the whole machine.
The compile job's 5000 and the browser's 5000 are translated into two completely different physical addresses. Neither program ever learns its own physical address, and neither can name a location belonging to the other. This is how Module 2's private address space is actually enforced.
The MMU. The memory management unit is a piece of hardware that sits between the CPU and the memory bus. Every address the CPU produces passes through it and comes out translated.
Two things about it matter:
- It is hardware, not software. No OS code runs per access — that would be hopelessly slow at a hundred million accesses per second.
- The OS sets up the tables the MMU reads, and the MMU does the lookups. The division of labour is: OS decides the policy, hardware does the work.
Why translation is worth the trouble. Three things fall out of it at once.
- Protection. A process cannot even express an address outside its own space, so it cannot corrupt another process.
- Relocation. The OS can move a process's memory to a different place in RAM and just update the table. The process notices nothing.
- The illusion. Each process behaves as though it owns memory starting at 0. That is the illusionist job from Topic 1.1, made concrete.
The speed gap. One number governs everything in Modules 6 and 7. On the Nova-14, RAM takes about 100 ns and pulling a page in from the SSD takes about 100 µs — a thousand times longer. Scaled so that a CPU register access takes one second:
- Register: 1 second.
- RAM: under two minutes.
- SSD page-in: over a day.
- A seek on the backup hard disk: about three months.
That is the gap the OS spends most of its effort hiding.
How it works
Every memory access the compile job makes:
- The CPU produces a logical address. As far as the program is concerned, this is the address.
- The MMU intercepts it before it reaches the memory bus.
- The MMU looks up the translation in the table the OS prepared for this process.
- It checks the access is legal. Out of range, or writing to a read-only page, and it raises a trap into the kernel instead.
- It emits the physical address and the RAM chip is read. The whole thing happens in hardware, in a fraction of the memory access itself.

Common confusion
"The compiler works out the real addresses." It cannot. The compiler has no idea where in RAM the program will end up, or whether it will be moved while running. It emits logical addresses and the translation happens at run time, on every access.
"The MMU is part of the operating system." It is hardware on the CPU. The OS fills in the tables it reads, but the OS is not in the loop for a normal access. If it were, every memory read would cost a mode switch.
"More RAM always makes things faster." Only up to the point where everything a program needs already fits. Beyond that, extra RAM does nothing — the machine is no longer waiting on the disk, and RAM speed itself has not changed.
Interview angle
"What is the difference between logical and physical addresses?" Logical is what the program sees and always starts at 0; physical is the real RAM location. Then add the consequence, because that is what the question is really probing: the separation is what makes protection and relocation possible.
"What does the MMU do?" It translates every address in hardware and checks permissions while doing so. The line worth saying out loud: the OS sets the policy, the hardware performs the translation.
- 1.
The compile job and the browser both access address 5000. What happens?
- 2.
Why is address translation done in hardware rather than by the OS?