Virtual Memory
Tom Kelliher, CS 240
Apr. 17, 2000
Collect homework.
New homework, due 4/26.
VM system support, VM performance, page fault sequence.
- Swap space policies.
- Replacement policies.
Placement policies, VM behavior (thrashing).
- Copy image into swap at process start-up. Demand paging done from
swap device. Wastes swap space, extra I/O, but swap device is faster than
filesystem.
- Demand page from filesystem. Read-only pages are never swapped out,
just overwritten and re-read from filesystem. Conserves swap space, uses
slower filesystem.
- Demand page from filesystem, swap out to swap device. Only demanded
pages are read from filesystem, only necessary pages are replaced to swap
device.
- What happens if a page fault occurs and all frames are in use?
- Must select a victim frame:
- Page-out victim frame.
- Update victim process' page table.
- Page-in faulted page.
- How do we select the victim frame?
- Comparison criteria for replacement algorithms.
- What is it?
- Where do I get one?
- What about redundancy?
- In the set of candidate victim pages, select the ``oldest'' page.
- Example reference string: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1,
2, 0, 1, 7, 0, 1. Three frames allocated.
- Belady's anomaly:
- Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5.
- Three frames allocated.
- Four frames allocated.
- Stack property: Set of pages in memory with n frames allocated is a
subset of set of pages in memory with n + 1 frames allocated.
- Replace the page which won't be used for the longest time.
- Example reference string: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1,
2, 0, 1, 7, 0, 1. Three frames allocated.
- Implementation?
- Approximation to optimal: replace page which hasn't been used for the
longest time.
- ``Reversal'' of optimal.
- Example reference string: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1,
2, 0, 1, 7, 0, 1. Three frames allocated.
- Implementation:
- Counters. Hardware support required
- Stack. Expensive.
- Reference bits concatenation as approximation to counter.
- Second chance (clock) algorithm: FIFO, but skip over page if
reference bit set (reset reference bit).
- Keep a small pool of empty frames so paging-in can occur without
waiting for victim page-out.
- When idle, write dirty pages out and clear dirty bit.
- Keep track of what's in free frames, so page-ins can possibly use an
old, free frame.
- Maintain frame list as a ``stack.'' Implementation?
- Timestamp page table entry on each access. Implementation?
- Simulating the time stamp through recording and concatenation of
reference bits.
- Implementation: system daemon and timer interrupt.
- How often to record?
- How many bits?
AKA clock algorithm.
- Maintain process' frame list in a circular queue.
- The ``victim'' pointer.
- Victim page referenced: skip over, resetting reference bit.
- All pages referenced: pure FIFO.
- Enhancement: examine (reference bit, dirty bit):
- Four combinations --- priorities?
- Possibly several passes through the queue.
Thomas P. Kelliher
Wed Apr 19 08:10:39 EDT 2000
Tom Kelliher