Virtual memory exists mostly for the programmerβs convenience; keeping programs out of each otherβs memory is the second reason, not the first.
Why this matters
That ordering explains the scale of what follows. All the hardware and bookkeeping of the coming chapters exist to maintain a convenient fiction β a large private memory that no program actually has β and the fiction earns its cost because programming without it is intolerable.The CPU is virtualized; surely thatβs the end of it?
The Professorβs roadmap: start simple, add complexity, tame the monster. Orange = virtual (the illusion), lime = physical (the reality) β a color pairing every diagram in the coming chapters reuses.
Tip: THE MANTRA β chant it like the Student does
Every address generated by a user program is a virtual address. Every pointer youβve ever printed, every value ofp in chapter 2βs mem.c
(remember two processes sharing 0x200000?), every stack and heap
address in every chapter ahead β virtual, all of it. The OS + hardware
translate each one to a physical address on the fly. If you hold onto
one idea across the next eleven chapters, hold this one.If you remember only three things
-
The monster is in the closet because of the volume, not the difficulty. The Professor warns about details to keep straight, not about hard ideas: base and bounds is simple, and the complexity arrives by accumulation.
-
A large contiguous address space is a promise, not a fact. Never having to ask where a variable should go is the product being sold, and it is sold to every program at once.
-
Memory virtualization needs the hardware on every access. The CPUβs mechanisms borrowed hardware at moments β a trap, a timer tick β while translating an address happens on every instruction, which is why this half needs so much more machinery.
Check yourself
1.What is THE mantra the Professor hands the sleep-deprived Student?
2.Why does the OS bother providing each process a large private address space? (Two reasons from the dialogue.)
3.How does the Professor plan to tame the memory monster?