Tech●●●●●Difficulty 3 of 5

Why does every program think it has the memory to itself?

Every program on your computer believes it owns a huge, private block of memory. The operating system and the processor are in on the trick.

▶ Start the story

Every program thinks it has the memory to itself because the operating system gives each one its own pretend set of addresses, called virtual memory. The program uses ; the operating system, with help from the processor, maps them onto real, physical addresses. A piece of hardware in the CPU, the , does the translating automatically. The result is an illusion of a very large main memory, and each program appears to have sole access to it.

Think of a hotel where every guest is told "your room is room 1". Each guest finds room 1 by their own key, and the front desk quietly sends one to the third floor and another to the seventh. The same virtual address in two programs can point to different physical memory, so a bug in one program cannot overwrite the other's data.

The trick also stretches memory. Because the mapping is only a mapping, some of a program's pages can live on disk. If the program touches one that is not in RAM, the processor raises a and hands control to the operating system, which loads the page and lets the program carry on.

Why bother? Memory used to be very expensive, so large programs had to carry their own code for juggling data between main memory and disk, a chore called . Virtual memory took that work off the programmers' plates, and it also brought isolation and security.

What a page fault does
  1. Step 1: Program touches a page

    Not currently in RAM

  2. Step 2:

    The processor hands control to the operating system

  3. Step 3: Page loaded

    From disk into a free spot in RAM

  4. Step 4: Instruction retried

    The program carries on and never notices

How virtual memory arrived
  1. 1959

    Working prototypes of

  2. 1962

    First Atlas commissioned at Manchester

  3. 1964

    Burroughs B5000: first commercial machine with virtual memory

  4. 1969

    IBM team ends the debate: virtual memory beats manual control

Quiz me

0/3

  1. 1.Two programs both use the memory address 5000. Why don't they overwrite each other?
  2. 2.What happens when a program touches a page that isn't in RAM?
  3. 3.Why do some embedded systems avoid virtual memory?

Recap

Programs use virtual addresses; the memory management unit translates them to real ones, and a page fault pulls missing pages in from disk.

💡 A trick to remember it · A hotel where every guest is told 'room 1' and the front desk quietly sends them to different floors.

Surprising fact · An IBM team showed in 1969 that virtual memory beat the best hand-managed memory systems.

Sources (4)

No source, no claim. Every fact in this lesson (16 claims) cites at least one of these.

  1. [1]Virtual memory · Wikipedia
  2. [2]Kernel (operating system) · Wikipedia
  3. [3]Paging · Wikipedia
  4. [4]Page fault · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗