Setting up
Two processes, A and B, run the same program. Each sees its own private memory, its address space: 16 KB of addresses from 0 up, holding its code, heap and stack. Both can use address 1000 without clashing.
Physical memory here is 64 KB, cut into four 16 KB slots. The kernel keeps slot 0 for itself and B already sits at 16 KB. To start A, it takes a free slot from its free list, 32 KB, and loads A there.
Before running A, the kernel sets two registers in the CPU's memory management unit (MMU): base = 32768, where A's slot starts, and bounds = 16384, its size. Setting them is privileged: only kernel mode may. Then A starts in user mode.
Translating
A runs line 1 and reads address 1000. The MMU checks 1000 < 16384, then adds the base: 1000 + 32768 = 33768. The read goes to physical address 33768, inside A's slot. The kernel is not involved.
A timer interrupt hands the CPU to the kernel. It saves A's base and bounds in A's process control block (PCB) and loads B's: base 16384, bounds 16384. Then it returns to B in user mode.
B runs the same line 1, address 1000. The MMU adds B's base: 1000 + 16384 = 17384, inside B's slot. Same virtual address, a different physical byte. B cannot even name A's memory.
Protection
Line 2 reads address 20000. The MMU checks first: 20000 is not below the bounds 16384, so it refuses. Without the check it would add the base and land on 36384, inside A's slot.
The refused access raises an exception. The CPU switches to kernel mode and jumps to the handler the kernel registered at boot. A user program cannot switch the check off: changing base or bounds is itself privileged.
The kernel sends B the signal SIGSEGV, whose default action ends it. It puts B's slot back on the free list, ready for the next process. A's memory was never touched, and A carries on.
Base and bounds is simple and fast: one compare and one add. But A's whole 16 KB slot is reserved, even the unused gap between its heap and stack. That waste is internal fragmentation. Segmentation, the next lesson, splits the address space up.
What happens
;; step 1/10 · illusion address space (what each process sees) 0 KB ......... code the program itself just above ... heap grows up ... free ... up to 16 KB .. stack grows down toward the heap every address the program uses is a virtual address: the kernel and the CPU decide where it really goes. A and B both say "address 1000"; they mean different bytes.
The machine is the tiny one from OSTEP chapter 15: 64 KB of physical memory and 16 KB address spaces. Real address spaces are far bigger; on x86-64 Linux each process has about 128 TB of user addresses. Linux, Windows and macOS do not use base and bounds: they use paging, covered later in this module. The idea is the same: every address is checked and translated by the MMU, and the kernel switches the translation on every process switch.