12. Intro to Memory Management Flashcards
What is time multiplexing?
Sharing a resource by dividing up access to it over time.
What are three examples of time multiplexing?
CPU scheduling on a single-core system
Classroom scheduling using temporal scheduling
Car share programs
What is space multiplexing?
Sharing a resource by dividing it into smaller pieces.
What are three examples of space multiplexing?
CPU scheduling on a multi-core system (low granularity)
Memory management (high granularity)
Splitting up a cake
What are the two main steps of memory allocation?
First, a process requests large chunks of memory from the OS kernel
(is this the address space?)
Second, the process divides the available memory up using a process-level allocation library (like malloc)
Why can’t we just divide physical memory up between processes (direct multiplexing)?
- We are limited to the amount of physical memory on the machine. Too many processes means we’d run out of memory.
- There is the potential for fragmentation, which reduces the efficiency of allocation
- Potential for discontiguous allocations, which complicates the process memory layout
What is the process memory layout concerned with?
It is concerned with how the process knows where its code and data are located.
What is fragmentation?
When a request for contiguous memory fails despite the fact that there is enough unused memory available (on the system)
What is internal fragmentation?
Fragmentation/unused memory inside an existing allocation
Ex: Firefox is given a block of memory but doesn’t use parts of it
What is external fragmentation?
Fragmentation/unused memory between existing allocations
(Ex: There is a small piece of unused memory in between the memory allocated for Firefox and the memory allocated for iMail)
Is it always feasible to splid data structures across multiple pieces of discontiguous memory?
No. For example, an int array data[10240] requires contiguous memory because of the way indexes are used to access elements within it.
What are the 5 main problems with direct multiplexing?
- We’re limited to the amount of physical memory on the machine
- We can get stuck with discontiguous allocations
- Potential for fragmentation, which reduces allocation efficiency
- Enforcing allocations (making sure the right process is accessing the mem address) requires checking permission for every memory access (very slow)
- Reclaiming unused memory leads to increased discontiguity
What are the 4 requirements for memory multiplexing?
Grant, enforce, reclaim, and revoke
What is the “grant” requirement for memory multiplexing?
The kernel should be able to allocate memory to processes statically (at startup) and dynamically (as needed)
What is the “enforce” requirement for memory multiplexing?
The kernel should be able to enforce memory allocations efficiently