Memory Manager
Addressing
- Physical Addressing
- Absolute location on memory chip
- Logical Addressing
- Relative
- Translated by the hardware and OS to actual physical locations
- Resolved during
- Development time
- Compile time (compiler sets special OS addresses)
- Link time (linker links static libraries)
- Load time (loading dynamic libraries)
- Run time
Safety
Physical Addressing (Old)
- Fence Register (very old)
- For uni-program systems
- Provide a division between OS and process memory
- Block a program from accessing any physical memory below the fence register
- Done by hardware on the MMU
- High/Low Registers
- For multi-programmed systems
- Uses high/low registers for each process to define the memory boundaries
- Still done by hardware but needs for the OS to update the values on each context switch
Logical Addressing
- Base and Limit Registers
- Logical memory always starts from 0 for every process but is stored in arbitrary physical memory
- Each process stores the base and limit
- Base = start of memory in physical memory
- Limit = end of memory in logical memory
- Checking
- When the logical address is greater than the limit, it traps for illegal access
- Add base register to the logical address to get physical address
- Use physical address
Approach
Tracking Free Space
- Bitmaps
- Have one bit represent if each block of memory is free or not
- Linear growth
- Linked List
- Option: Track Everything
- Option: Track Holes
Finding Free Space
- First Fit: First hole big enough
- Next Fit: Next hole big enough
- Best Fit: Smallest hole big enough
- Worst Fit: Find the largest hole available
- Quick Fit: Separate list of commonly requested sizes
Process Partitioning
-
Multiple Fixed Partitions
- Fixed list of fixed size partitions have a fixed size
- Shared Queue
- Has a single queue of processes and they get placed in partitions that can fit them
- Can have a small process take a big partition
- Separate Queues
- Looks at how big a process is and then assigns it to a queue for a partition of similar size
- Decreases internal fragmentation
-
Multiple Variable Partitions
- Partitions can change over time to accommodate process load
- Prevents internal fragmentation but has external fragmentation
- Because there is space left over between processes
-
Fragmentation
- When memory is split up into sections that are too small to use
- Internal
- Memory is fragmented within a process
- Examples
- Unusable amount of space between the heap
- Small gaps within the heap
- No solution
- External
- Memory is fragmented in the space between processes
- Solutions
- Fixed memory partitioning (ugh)
- Compaction
- Reorders processes
- Uses CPU time to reorganize
- Paging & Segmentation
Loading into Memory
Overlays
- Part of memory stored on disk, swapped out as needed
- User space approach (no OS involvement)
- Ex: cut scene where part of game gets replaced in memory with something that was stored on the disk