Ch. 8 - Memory Management Flashcards
What are the 3 most common forms of locality?
> Temporal Locality
Spatial Locality
Branch Locality
Temporal Locality (Definition and Example)
A referenced memory location is likely to be referenced again soon after. (eg. loops)
Spatial Locality (Definition and Example)
If a memory location is referenced, it is likely that nearby locations will be accessed soon after. (eg. array traversal)
Branch Locality
Branching of code is limited to a few nearby possibilities.
What are the benefits of using locality of reference?
> Reduce the number of page faults (access the same page over and over again)
More TLB and cache hits (less likely to go to disk to get data)
What are some issues in sharing memory?
> Transparency (several processes need to co-exists, unaware of each other)
Safety (processes cannot corrupt each other or the OS)
Efficiency (low overhead needed)
Relocation (programs can run in different memory locations)
What are the steps a program must go through before being executed by the CPU?
- Compiling (generate object code)
- Linking (combine object code into executable code)
- Loading (copy the executable code into memory, do any necessary run-time linking with libraries)
- Execution (dynamic memory allocation during program execution)
Direct Placement (Memory Management Scheme)
Load entire user program (code, data, etc.) into the same memory location. The linker produces the same loading address for every user program.
Fastest memory management scheme
Overlays (Memory Management Scheme)
Program is organized into a tree-like structure. Root of overlay always loaded into memory while sub-trees a re loaded as needed by overlaying existing code.
Static Partitioning
Main memory is divided into a fixed number of fixed size partitions (small jobs, medium jobs, large jobs). Multiple jobs can run concurrently sharing the CPU (1 small, 1 medium, 1 large)
Dynamic Partitioning
Allow for any number of programs to be loaded into memory as long as there is enough room. Each program is allocated the exact amount of memory it needs.
What is an issue of using static partitioning?
Wasted memory if there isn’t a job to execute that can fit in each partition (internal fragmentation)
What is an issue with dynamic partitioning?
When programs finish, the space freed may be too small to run a new program (external fragmentation)
Internal Fragmentation
Waste of memory within a partition (difference between size of partition and size of process loaded)
External Fragmentation
Waste of memory between partitions (scattered non-contiguous free space).