Memory Management I
Tom Kelliher, CS 318
Mar. 11, 1998
Announcements: Homework 2 due Friday.
From last time:
- CPU scheduling: criteria, algorithms.
- Gantt chart examples.
- Address binding, loading, libraries, and overlays.
- Logical and physical address spaces.
- Contiguous and non-contiguous allocation.
Assignment: Read Chapter 8.
Assumption: several processes competing for memory. Questions:
- How is memory allocated among processes?
- Contiguous/non-contiguous allocation?
- Fixed- or variable-sized allocation chunks?
- Over-commitment. What happens?
- Sometimes, a program can't be loaded ``just anywhere'' in memory.
- When does a symbolic name become associated with a memory location?
- How is that location addressed? (Direct, indexed, indirect, etc.)
Address binding options and consequences
- Compile time. Absolute (direct) addressing used. Program
must be loaded into memory at a fixed location. MS-DOS .COM
- Load time. Compiler/linker insert ``dummy'' references in code.
Loader knows load address at run time, finds and fixes-up dummy references.
- Addressing modes?
- Re-location? Must re-load to re-locate.
- Run time. Pc-relative or base addressing. Base register points to
- On-demand module loading --- ``lazy'' loading.
- Load only what's necessary.
- Static linking --- link at compile-time.
- Larger binaries --- wasted disk space.
- Must re-link source when updating libraries.
- Dynamic linking (shared libraries) --- link at run-time.
- Smaller binaries.
- Stubs: locating the library in memory or on disk.
- Automatic library updates to fix library faults in all
binaries. (With static must re-link all binaries.)
- Shared libraries. Major (new version #) and minor (same version
- DLLs in Wintel world. Broken programs.
- Compiler issue: code scheduling for out-of-order execution model
- Static (compile-time) optimization. VLIW model.
- Dynamic (run-time) optimization. DIF model.
- Intel IA-64.
Umm, my program is larger than physical memory. What do I do? Example:
Logical = Virtual
- Program (CPU) generates logical addresses.
- MMU converts them to physical addresses.
- Compile-time, load-time binding: physical address = logical address.
Simple MMU scheme:
Note: Program can utilize compile-time binding.
- Process must be entirely in memory to execute.
- If in ready Q, can swap-out to ``backing store.''
- If in I/O wait must ``lock'' in memory. Why?
- Must process be swapped-in to same memory space? Depends on loader
- What needs to be swapped out, exactly? The entire partition? The
entire process space?
- Swapping in Unix occurs:
- The system page map has become too fragmented to allocate page
tables for some process.
- There are at least two runnable processes, the average amount of
free memory has been less than that desired ( desfree) over the
last 5 and 30 seconds, and either the paging rate is excessive or the
short-term average free memory is less than minfree.
- A swapped-out process is ready to run and a process is found in
memory that has been sleeping for at least 20 seconds; or the
swapped-out process has been out for at least 10 seconds and the process
chosen for swapping out has been in memory at least 20 seconds.
What are we leading up to, here?
- Only one process in memory at a time.
- Must swap to do a context switch. Speed?
- Unused Memory: internal fragmentation.
- Partitions usually of differing sizes.
- Job placement policy.
- Can swap jobs in and out of partitions.
- Internal fragmentation.
- Number of partitions varies.
- Partitions allocated according to process requirements.
- What if a process grows?
- Free list of unallocated holes.
- Placement policies:
- First fit. Best time.
- Best fit.
- Worst fit --- worst time, storage utilization.
- External fragmentation.
- Combining adjacent holes.
- Memory compaction --- must be using relocatable code. Minimizing
Thomas P. Kelliher
Mon Mar 9 08:40:57 EST 1998