OPERATING SYSTEM NOTES
3. MEMORY MANAGEMENT
3.1. Memory management Concepts
Here's a simplified version of your notes on Process Address Space, ideal for exam prep or quick understanding:
Process Address Space
What Is Process Address Space?
It's the range of memory addresses (logical/virtual) a process can access.
Types of Memory Addresses
Type | Description | |
---|---|---|
1️⃣ | Symbolic Address | Used in source code (e.g., variable names, labels like x , main: ). |
2️⃣ | Relative Address | Created by the compiler, relative to the program’s start. |
3️⃣ | Physical Address | Final memory address used by hardware. Created when the program is loaded. |
Key Terminology
Term | Meaning |
---|---|
Logical Address | (a.k.a. Virtual Address) – Generated by the CPU during execution. |
Physical Address | Actual address in main memory (RAM). |
Logical Address Space | All logical addresses a program can use. |
Physical Address Space | All physical memory addresses accessible in RAM. |
Address Binding Types
Type | When Virtual = Physical? | Description |
---|---|---|
Compile-time | Yes | If memory location is known at compile-time. |
Load-time | Yes | If memory location is decided when program is loaded. |
Execution-time | No | Uses MMU to map virtual → physical at runtime (most common). |
Memory Management Unit
-
A hardware device.
-
Maps virtual addresses (used by processes) to physical addresses (used by RAM).
-
How It Works:
-
Suppose base register =
10000
-
If program accesses address
100
, MMU adds base:100 + 10000 = 10100
→ This is the physical address used.
-
N/B
-
Virtual addressing allows for memory protection and multitasking.
Static vs Dynamic Loading & Linking
1. Loading
Type Static Loading Dynamic Loading When? Done at compile/load time Done at runtime How? Entire program (including all modules) is loaded into memory before execution starts Only needed modules are loaded when required Speed Faster execution (everything is preloaded) Slower initially (modules loaded on demand) Memory Use Higher – loads everything up front More efficient – loads only what's needed
2. Linking
Type Static Linking Dynamic Linking When? Happens at compile time Happens at runtime How? All code from external libraries/modules is copied into the executable Only a reference to external library is included Examples .exe
files with all code insideWindows: (Dynamic Link Library) Unix: (Shared Object) Executable Size Bigger (includes everything) Smaller (just contains references) Flexibility Less flexible – changes require recompilation More flexible – library updates don’t require recompiling
Key Differences Summary
Feature Static Dynamic Loading time Compile/load time Runtime Linking time Compile time Runtime Speed Faster Slower (initially) Flexibility Low High Memory efficiency Low High
When to Use
-
Static: Use when you want faster performance, no external dependency, or a standalone executable.
-
Dynamic: Use when you want modular code, shared libraries, and easier updates.
-
User programs only see virtual addresses – never actual physical memory.
-
MMU handles all conversions automatically and securely.
-