CSE Roadmap

Core tier · about 4 hours · 6 parts

Part 2 of 6 · 2 min read

The problem

Think of it this way. A hotel has 100 rooms and many guests. If each guest were told "your room is wherever the free space is, work it out yourself", guests would walk into each other's rooms. The hotel gives each guest a key to one room, and the room is always called "room 1" from the guest's point of view, whichever real room it is. The analogy stops in one place: a hotel room has a fixed size, while the memory of a process can grow and shrink.

In plain words: Early computers ran one program at a time, and the program could use all the memory. Once several programs share a machine, three needs appear:

  • Protection. A bug or an attack in one process must not read or change the memory of another process, or of the kernel.
  • Sharing of the machine. The memory must be divided among the processes in a fair and efficient way, and the total of what processes ask for may be larger than the memory installed.
  • Convenience. A programmer should write p = 0x1000 and not need to know where in the real memory the program was loaded.

The answer is the address space: for each process, a private numbered range of addresses that the process may use. Different processes can use the same numbers, and the numbers mean different real places.

Address space

An address space is the range of memory addresses that a process can use, a private view that the operating system and the hardware map onto the real memory and keep separate from the views of other processes.

Example: two processes can both store a value at address 0x601040, and the two values are kept in different places in the real memory.

Check yourself: 1. Name the three needs that appear once several programs share a machine. 2. Why can two processes use the same address number without damaging each other? 3. In the hotel analogy, what plays the part of the room key?