Winter Semester 2026–27 · VIT-AP · BACSE106 · Operating Systems · Dr. Krithika L.B

Session 4.1: Address binding, logical and physical address space

How the addresses in a program become real memory addresses — at compile, load or run time — and how the MMU and base/limit registers relocate and protect each process.

Module 4 1.5 hours Theory CO4
← Before
3.6 Monitors
End of Module 3
You are here
4.1 Address binding, logical and physical address space
Module 4 · Memory and File Management
Next →
4.2 Contiguous allocation
Placement and fragmentation

Learning objectives

By the end of this session you should be able to:

  • Explain how base and limit registers protect processes from each other.
  • Distinguish compile-time, load-time and execution-time address binding.
  • Differentiate logical and physical addresses and compute a physical address with a relocation register.
  • Explain dynamic loading, dynamic linking and shared libraries.
  • Describe swapping and its cost.

Lecture notes

1. Background: memory and protection

Every process from Module 2 needs its instructions and data in main memory — the only large storage the CPU can address directly. With many processes in memory at once (multiprogramming), the OS must answer three questions: where does each process go, how are its addresses translated, and how is it protected from the others?

The simplest protection uses two registers loaded by the kernel on every context switch: a base register (smallest legal physical address) and a limit register (size of the range). The hardware checks every user-mode address:

CPU address→ ≥ base ?→ < base + limit ?→ memory

If either test fails → trap to the OS (addressing error). Only the kernel can load base and limit — they are privileged instructions (Session 1.3).

2. Address binding

A program refers to memory symbolically (count, main). Along the way to execution, these addresses are bound to real memory addresses. Binding can happen at three stages:

The programmer writes count = count + 1; — a symbolic address.

If the compiler knows where the process will live, it generates absolute code (e.g. count at 74014). If the start location changes, the program must be recompiled. Example: MS-DOS .COM programs.

Otherwise the compiler generates relocatable code (“14 bytes from the start of this module”). The loader binds to absolute addresses when the program is loaded. If the start changes, just reload.

If a process can be moved during execution (e.g. swapped out and back to a different place), binding is delayed until run time. Needs hardware support — the MMU. All general-purpose OSes use this.

The full path: source → compiler → object module → linker (+ other modules, libraries) → load module → loader (+ dynamically linked libraries) → in-memory binary image.

3. Logical vs physical address space

Logical (virtual) address

Generated by the CPU — what the program sees. The set of all of them is the logical address space.

Physical address

Seen by the memory unit — what is loaded into the memory-address register. The set is the physical address space.

With compile-time and load-time binding the two are identical; with execution-time binding they differ, and the Memory-Management Unit (MMU) maps logical to physical at run time. The simplest MMU adds a relocation register (the base register) to every address:

Worked example — dynamic relocation

Relocation register = 14000, limit = 3000. The program issues logical address 346.

Check 346 < 3000 ✔ → physical address = 14000 + 346 = 14346.

Logical address 3500 → 3500 ≥ limit → trap. The program only ever sees addresses 0 – 2999; it never knows it lives at 14000.

CPU: logical 346→ < limit 3000?→ + relocation 14000→ physical 14346

4. Dynamic loading, dynamic linking and shared libraries

  • Dynamic loading: a routine is not loaded until it is called. Unused code (error handlers) never occupies memory.
  • Static linking: library code is copied into every executable.
  • Dynamic linking: linking is postponed to execution time. A small stub locates the library routine in memory; one copy of libc.so / .dll is shared by all processes, and updating the library updates every program. Try ldd /bin/ls.

5. Swapping

A process can be swapped temporarily out of memory to a backing store (fast disk) and brought back later — the medium-term scheduler of Session 2.1. Swapping lets the total memory of all processes exceed physical memory, but moving a whole process is slow: a 100 MB process at 50 MB/s takes 2 s each way. Modern systems swap individual pages instead (Session 4.5), and mobile OSes usually terminate background apps rather than swap.

VideoBytes

Address binding and the MMU

Video coming soon

Address binding and the MMU

Recorded by Dr. Krithika L.B. Slot m4-address-binding

Interactive lessons

Work through these in order after the lecture — each one expands a part of the notes with diagrams, hover notes and a quick check.

Lab connection

Check your understanding

Answer each question in your own words first, then reveal the model answer.

Revealed 0
Relocation register 5000, limit 1200. Translate logical addresses 100 and 1300.

100 → 5100. 1300 ≥ 1200 → trap (addressing error).

Which binding time allows a process to move in memory while it runs?

Execution-time binding, with MMU hardware.

Why must loading the base and limit registers be privileged?

Otherwise a user program could change them and access any memory, defeating protection.

Give one advantage of dynamic linking.

One shared copy of a library serves all processes (less memory and disk), and library updates apply without recompiling programs.

Key takeaways

  • Base and limit registers give hardware memory protection.
  • Binding can happen at compile, load or execution time; execution-time binding needs an MMU.
  • Logical addresses are what programs see; the MMU maps them to physical addresses (physical = relocation + logical).

Where this leads

With an MMU we can put a process anywhere. But where exactly, when memory is a patchwork of free holes? Next: contiguous allocation and placement algorithms.

Continue to 4.2 — Contiguous memory allocation and fragmentation →