Memory Management II
Tom Kelliher, CS 318
Apr. 3, 1998
Announcements:
From last time:
- Loose ends, midterm
Outline:
- Address spaces.
- Contiguous schemes.
- Non-contiguous schemes.
Assignment: Read Chapter 8.
Logical = Virtual
Recall:
- 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
design.
- 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.
Key: contiguous.
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
copying.
Problems with contiguous allocation:
- Problems with fixed partitions:
- Limited degree of multiprogramming.
- Internal fragmentation.
- Placement policies.
- Problems with variable partitions:
- External fragmentation, compaction.
- Swapping is difficult, if not impossible (address binding).
Alternative: non-contiguous allocation.
The idea:
- Entire process in memory.
- Partition memory into frames of size .
- Typical frame sizes: 512 to 8K bytes.
- Frame size constrained by MMU design.
- Logical address space is broken into pages.
- Page size = frame size.
- Pages can be arbitrarily mapped onto frames.
- However, process ``sees'' a contiguous, flat address space.
- MMU splits logical address:
- Assume logical address is n bits.
- Page number field is n - m most significant bits.
- Page offset field is m least significant bits.
- Using table look-up, convert logical page number to physical frame
number.
- Frame offset = page offset.
Why is frame, page size a power of two?
Paging hardware:
Design issues:
- Page size:
- Internal fragmentation.
- Maximizing I/O transfer rate.
- I/O --- process passes logical address to kernel.
- Implementation of the page table.
- Small register file.
- Array in memory.
- Issues for memory implementation:
- Page table must be in contiguous memory.
- Page table base register.
- ``Logical memory access'' requires two physical accesses.
- Translation look-aside buffer.
- TLB entries contain: Page number, frame number pairs.
- Issue: Context switches.
- Only a few entries needed.
- Problem: huge page tables. How did this happen?
- Solutions:
- Valid/invalid bit.
- Page table limit register.
- Multi-level paging.
Why not just use the limit register?
A two-level paging scheme for a 32-bit logical address:
Is the page table really any smaller?
What does this solve?
- Non-contiguous (paged) page table.
- ``Holes'' in page table (valid bit) shrink it.
Sun SPARC: 3 level paging.
64-, 128-bit logical addresses?
- Is it possible for a process to access an arbitrary memory location?
- Using valid bit to introduce ``holes'' into logical address space.
- What can be shared?
- Read-only pages.
- Page alignment --- segment the logical address space.
- Page de-allocation.
- ``Object oriented'' approach:
- User views program as a set of objects:
- Stack.
- Routines.
- Arrays.
- ...
- Each object stored in a segment.
- Generalization of paging.
- Logical address is a segment ``name'' and an offset.
- Variable-sized ``page'' having a base and length.
- Frames start on memory boundaries. Segments start anywhere.
Therefore, must add a segment base and offset.
- Straight paging: external fragmentation.
- Solution: Paged segmentation (x86 architecture).
Segmentation hardware:
Thomas P. Kelliher
Thu Apr 2 15:13:09 EST 1998
Tom Kelliher