Topic 7.1 · Memory Management & Allocation

Logical vs. Physical Address Space & MMU

3 min read1 question to test yourself

1Definition

Logical Address (Virtual Address) is a memory address generated by the CPU during instruction execution. Physical Address is the actual physical hardware location loaded into the Memory Address Register (MAR) of primary RAM. The Memory Management Unit (MMU) is a hardware device on the CPU that performs runtime translation from logical addresses to physical addresses using Relocation and Limit Registers.

2Simple Explanation

When a developer writes a program, the compiler generates instructions starting at address 0 up to max (Logical Address Space). The user program believes it owns memory starting from 0. However, in a real computer with multiple apps open, address 0 in physical RAM is already occupied by the operating system kernel. The MMU hardware sits between the CPU and physical RAM. When the CPU requests logical address 356, the MMU automatically adds a relocation base value (e.g., 14000), outputting physical address 14356 to RAM.

3Real-Life Example / Analogy

Apartment Unit Numbers vs. Postal Street Address: Inside an apartment building, rooms are labeled simple logical numbers: Apt 1, Apt 2, Apt 3 (Logical Addresses). The delivery driver outside needs the complete global physical address: 742 Evergreen Terrace, Apt 3 (Physical Address). The Mailroom Sorting Desk (MMU) takes incoming mail addressed to Apt 3 and delivers it to the building's physical geographic location.

4Diagram / Visual Representation

No

Yes

CPU generates logical address

Address < Limit register?

Trap · Addressing error

Add relocation / base register

Physical address = Base + Logical address

Access physical memory (RAM)

5Working / How It Works

  1. Instruction Fetch: CPU generates a logical address LL for a memory read/write.
  2. Bounds Checking: MMU compares LL against the Limit Register.
    • If L≥LimitL \ge \text{Limit}, MMU triggers a hardware Trap (Addressing Error / Segmentation Fault) to the OS.
  3. Address Relocation: If L<LimitL < \text{Limit}, MMU adds the Relocation Register (Base RR) value to LL: Physical Address P=R+L\text{Physical Address } P = R + L
  4. RAM Access: MMU sends physical address PP over the memory bus to primary RAM.
  5. Context Switch Update: When switching processes, the OS dispatcher updates the Relocation and Limit registers with the new process values.

6Types / Components / Characteristics

  • Logical vs. Physical Address Space Comparison:
Metric / Attribute Logical Address (Virtual Address) Physical Address
Generated By CPU Core Memory Management Unit (MMU)
Visibility Directly visible to program & developer Hidden from user programs; hardware level only
Location Virtual address space Hardware RAM memory chips
Address Range 00 to Max\text{Max} (R+0)(R + 0) to (R+Max)(R + \text{Max}) for Base RR
Existence Virtual software representation Physical electronic storage location
  • Hardware Protection Registers:
    • Relocation Register (Base): Holds smallest physical address location where process starts in RAM.
    • Limit Register: Holds size of logical address space; prevents processes from accessing memory belonging to other processes or the OS.

7Solved Examples / Problems

Problem: A process has a Relocation Register value of 100040 and a Limit Register value of 74600. Calculate the physical address for logical address 30000. What happens if CPU generates logical address 80000? Solution:

  1. For Logical Address 30000:
    • Check Limit: Is 30000<7460030000 < 74600? Yes (Valid).
    • Physical Address = Base+Logical=100040+30000=130040\text{Base} + \text{Logical} = 100040 + 30000 = \mathbf{130040}.
  2. For Logical Address 80000:
    • Check Limit: Is 80000<7460080000 < 74600? No (Out of Bounds!).
    • Result: MMU blocks access and raises a Trap (Fatal Memory Addressing Error) to the OS.

8Advantages, Disadvantages & Applications

  • Advantages: Complete memory isolation and protection between processes; enables dynamic process relocation in RAM.
  • Disadvantages: Requires dedicated MMU hardware circuits.

9Important Points to Remember

  • Logical addresses range from 00 to Max\text{Max}; Physical addresses range from RR to R+MaxR + \text{Max}.
  • Relocation registers provide hardware-level memory protection.

10Test Your Understanding

  1. MCQ: Which hardware component is responsible for performing dynamic runtime translation of logical addresses to physical memory addresses?
    • A) Control Unit
    • B) Memory Management Unit (MMU)
    • C) Bootloader
    • D) Short-Term Scheduler
    Show answer
    B.
  2. Conceptual Question: Explain how the Relocation Register and Limit Register work together to enforce memory protection.
  3. Application Question: Given Relocation = 5000 and Limit = 2000, evaluate validity and physical addresses for logical addresses 1500 and 2500.

Finished this topic?

0 of 27 topics read in Operating Systems

Handwritten notes for the exam

Unit-wise SPPU notes and PYQs for this subject.

Helpful? Share it with your class

Free for everyone, no login needed.

Share topic