Chapter 15: Understanding Address Translation in Virtual Memory

Nov 7, 2024

Mechanism: Address Translation

Introduction to Virtualization

  • Limited Direct Execution (LDE):
    • Programs primarily run directly on hardware.
    • OS intervenes at critical points (e.g., system calls, timer interrupts).
    • Aims to balance efficiency with control over hardware.
  • Virtual Memory Strategy:
    • Similar approach to CPU.
    • Hardware support is crucial for efficiency (e.g., TLBs, page tables).
    • Ensures applications only access their own memory, providing protection.
    • Flexibility for programs to use address spaces optimally.

Address Translation

  • Hardware-Based Address Translation:
    • Hardware transforms virtual addresses to physical ones.
    • OS manages memory, setting up correct translations.
    • Goal: Illusion of private memory despite shared physical memory.
  • Interposition:
    • Technique where hardware intervenes in memory access.
    • Provides transparency without changing client interface.

Assumptions in Virtualizing Memory

  • Address space must be contiguous and smaller than physical memory.
  • Each address space is assumed to be the same size.

Example of Address Translation

  • Address translation transforms virtual addresses to physical memory locations.
  • Example code sequence demonstrates loading and storing values in memory.
  • Physical memory layout example shows process relocation.

Dynamic (Hardware-based) Relocation

  • Base and Bounds Registers:
    • CPU uses these for memory address translation.
    • Base register sets starting physical memory address.
    • Bounds register ensures memory references are within legal limits.
  • Address Translation Process:
    • Adds base register value to virtual address to get physical address.
    • Uses bounds for protection against illegal memory access.

Hardware Support

  • Requirements:
    • Privileged CPU modes.
    • Base and bounds registers as part of the Memory Management Unit (MMU).
    • Privileged instructions to set register values and handle exceptions.

Operating System Issues

  • Responsibilities:
    • Memory management and allocation upon process creation.
    • Base/bounds management during context switches.
    • Exception handling for illegal memory accesses.
  • Dynamic Relocation Challenges:
    • Efficient memory utilization, avoiding internal fragmentation.

Summary

  • Address translation allows for efficient memory virtualization.
  • Base-and-bounds system provides quick translations and protects processes.
  • Provides the illusion of continuous memory while sharing physical memory resources.

References

  • Various papers and resources detailing the history and techniques of dynamic and static relocation.

Homework (Simulation)

  • Experiment with relocation.py to understand address translation using base and bounds registers.
  • Various simulation questions to explore bounds, base settings, and memory allocations.