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
What is the “reclaim” requirement for memory multiplexing?
The kernel should be able to repurpose unused memory without destroying its contents
What is the “revoke” requirement for memory multiplexing?
The kernel should be able to stop a process from using memory that it was previously allocated
What is the “grant” requirement a CPU?
CPU must be able to schedule a thread via a context switch
What is the “enforce” requirement a CPU?
CPU must be able to interrupt a thread using a timer interrupt
What is the “reclaim” requirement a CPU?
?
“This is new”
What is the “revoke” requirement a CPU?
CPU must be able to reschedule a thread via a context switch
Which abstraction is the memory management abstraction? (and how?)
The address space.
We provide every process with an identical view of memory that makes it appear plentiful, contiguous, uniform, and private
What is the principle service (benefit) of the address space layout?
The uniformity of the address space simplifies the process layout.
It allows a process to always put things like static variables, the heap, and the stack at the same addresses
Where is the process layout (convention) specified?
In the Executable and Linker Format (ELF) file
Why don’t ELFs typically load process code at address 0x0?
To catch possibly the most common programming error, a NULL pointer problem.
We want to set up an environment where a pointer to 0x0 is not valid unless explicitly specified to be.