Outline 2/4/98
- Last time: Paging: what it is and why (what problems of other organizations it solved)
- Administrative: Mid-course evaluation
- Objective today: Segmentation as a memory organization. Virtual memory issues, policies.
Paging and Sharing (Difficulties)
- Virtual address spaces still look contiguous.
- Virtual Address Space for Process 0 links foo into pink address region
- Virtual Address Space for Process 1 links bar into blue region
- Then along comes Process 2 ...
Sharing in Segmentation
- Naming is by logical objects.
- Offsets are relative to base of object.
- Address spaces may be sparse as well as being non-contiguous.
Virtual Memory Issues
- Hardware support - beyond dynamic address translation needed to support paging or segmentation (e.g., table lookup)
- mechanism to generate page fault on missing page.
- restartable instructions
- Software
- Replacement, fetch, and placement policies.
- Data structure for location in secondary memory of desired page.
Good & Bad Locality
for (i = 0; i++; i<n)
for (j = 0; j++; j<m)
A[i, j] = B[i, j]
for (j = 0; j++; j<m)
for (i = 0; i++; i<n)
A[i, j] = B[i, j]
Demand Paging
- Missing pages are loaded from disk into memory at time of reference (on demand
The alternative would be to prefetch into memory in anticipation of future accesses (need good predictions)
- Page fault occurs because valid bit in page table entry (PTE) is off. The OS:
- allocates an empty frame*
- reads the page from disk
- updates the PTE when I/O is complete
- restarts faulting process
*Page Replacement
- When there are no free frames available, the OS must replace a page (victim), removing it from memory to reside only on disk (backing store), writing the contents back if they have been modified since fetched (dirty).
- Replacement algorithm - goal to choose the best victim, with the metric for "best" (usually) being to reduce the fault rate.
Assessing Replacement Algs
- Model program execution as a reference string
- Comparison of algorithm performance (fault rate) to that of Optimal Algorithm.
- For a specific algorithm: What is the information needed? How is that information gathered? When is it acted upon?
- At each memory reference
- At fault time
- At periodic intervals
Replacement Algorithms
- Optimal - baseline for comparison - future references known in advance - replace page used furthest in future.
- FIFO
- Least Recently Used (LRU) -
stack algorithm - don't do worse with more memory.
- LRU approximations for implementation -
Clock, Aging register
Variable Space Algorithms
- Working Set
Tries to capture what the set of active pages currently is. The whole working set should be resident in memory for the process to bother running. WS is set of pages referenced during window of time (now-t, now).
- Working Set Clock - a hybrid approximation
- Page Fault Frequency
Monitor fault rate, if pff > high threshold, grow # frames allocated to this process, if pff < low threshold, reduce # frames.
Idea is to determine the right amount of memory to allocate.