Logical versus Physical Address Space
Problem:
- Suppose Process A uses memory with addresses 0 to 1M.
- Process B uses memory with addresses from 2M to 3M.
- Process A tries to access memory at address 2.5M.
- What happens?
- Answer: the hardware needs to detect this!
Terminology:
- Addresses generated by the CPU are called logical addresses.
- These are sometimes also called virtual addresses.
- Addresses seen by the memory system are called physical addresses.
- The mapping from logical address to physical address is
done by a hardware device called a memory management unit or MMU.
- Typically, the MMU only has to handle translation for the
currently running process.
- We need one MMU per CPU.
Memory Introduction 1
Partitions for Memory Management
- Fixed Partitions:
- Divide up the memory into fixed pieces called partitions
(not necessarily equal).
- Each partition contains at most one process.
- All logical addresses start at 0.
- A base register and a limit register are used to relocate and
protect.
- physical address = logical address + base register (relocation).
- MMU checks that physical address is between the base register and
the limit register (protection).
- When a job is scheduled it is put into a particular partition.
- If the job is a lot shorter than its partition, that space is wasted
for duration of job (internal fragmentation).
- If a partition is too small for any of the current jobs, that
partition sits idle (external fragmentation).
- If job is larger than any partitions, you are out of luck.
- Variable Partitions
- Like fixed partitions but:
- Partition sizes are determined dynamically to match the
current job sizes.
- The operating system keeps a table of current partitions.
- When a job finishes, it leaves a hole.
- Eventually there are holes everywhere which must be consolidated
(fixes external fragmentation).
This is called compaction.
Memory Introduction 2
Swapping
Swapping refers to temporarily moving a process out of memory to a
backing store, usually a disk, and then bringing it back into memory
to continue its execution.
Swapping can be used to free up memory for additional procsess.
This takes too much time to be used often.
Next Notes
Back to CS 3733 Notes Table of Contents