l3
"/home/yossef/notes/Su/os2/l3.md"
path: Su/os2/l3.md
- **fileName**: l3
- **Created on**: 2026-01-03 19:58:11
This lecture covers Memory Management, which explains how an
operating system handles and organizes the computer's primary
memory to ensure programs run efficiently.
1. Core Concepts and Background
For a program to run, it must be brought from disk into
main memory and placed within a process. The CPU can only
directly access main memory and its internal registers.
- Registers: Extremely fast storage accessible in one
CPU clock cycle or less. - Main Memory: Slower storage that can take many
CPU cycles to access. - Cache: A faster memory layer between main memory
and CPU registers to speed up access.
2. Address Spaces and Mapping
A key concept in memory management is the distinction
between two types of addresses:
- Logical Address (Virtual Address): Generated by
the CPU during program execution. - Physical Address: The actual address seen by the
memory hardware. - Memory-Management Unit (MMU): A hardware device
that maps virtual addresses to physical ones.
In an MMU scheme, a relocation register value is added
to every process-generated address to locate it in memory.
3. Dynamic Loading and Swapping
These techniques improve memory efficiency:
- Dynamic Loading: A routine is loaded into memory
only when it is called, saving memory space. - Swapping: A process may be temporarily moved from
memory to a backing store and later restored.
4. Memory Allocation and Fragmentation
Memory allocation often involves holes, which are
free blocks scattered throughout memory.
- Contiguous Allocation: Each process occupies one
continuous block of memory. - External Fragmentation: Enough total memory exists,
but it is broken into noncontiguous pieces. - Internal Fragmentation: Fixed-size allocation leaves
unused space within allocated blocks.
5. Paging and Segmentation
Two major noncontiguous memory management techniques:
- Paging: Logical memory is divided into fixed-size
pages, while physical memory uses frames. - A page table translates page numbers into frame
addresses. - TLB (Translation Look-aside Buffer): A fast hardware
cache that speeds up address translation. - Segmentation: Memory is divided into logical units
like the main program, stack, or symbol table.
Analogy to Solidify Understanding
Memory management is like a library:
- Paging: Every book page is the same size, and the
library has perfectly fitting shelves. - Segmentation: The library is divided into sections
like Science or History, each with different sizes.
for the report(quiz and some answers) ./l3_report.md
mind map
