Page replacement design Flashcards
What design decisions have to be made?
Frame allocation algorithm: How memory frames are allocated among processes
Page replacement algorithm: How victims will be chosen
How are algorithms evaluated?
Run the algorithm against some test data, where the test data is a sequence of reference strings.
Can also trace a running system to produce large amounts of data.
What is a reference string??
Record only page number, consecutive duplicates are eliminated.
How does FIFO replacement work?
Replace the page that was brought in first.
Record the time that each page was faulted.
How can we optimise the FIFO solution?
Interested in order, not time. Create FIFO queue and replace pages at the head of the queue.
When page is faulted, insert at back.
What are the drawback of FIFO replacement?
May replace heavily used pages. IE:
Variable written at start of program that is used throughout but will be replaced.
What is the FIFO anomaly?
intuitive results due to Belady’s anomaly.
Page fault rate may increase when number of frames is increased.
What is an optimal algorithm for page replacement?
Replace the page that will not be used for the longest time
What is the implication of the optimal algorithm?
Impossible to implement as we can’t predict the future.
What is the optimal algorithm used for?
Comparison purposes, calculate the best possible performance of a reference string.
What is LRU?
Least recently used , replace the page that hasn’t been used for the longest time.
Optimal algorithm except it looks back in time.
How is memory determined by the LR?
Pages in memory are the n most recently used pages.
For n+1 frames these n pages would still be in memory.
How does LRU work with counters?
Logical CPU clock held in register, incremented on each memory reference.
Page table entry contains counter value at last use, have to search page table for smallest value.
How does LRU work with the stack?
Maintain a stack of page numbers.
On reference, remove from stack and push on top.
Replace page at bottom of stack.
What support does LRU require?
Hardware support, clock or stack approach require memory update on every reference.
Interrupt on ever memory reference.
What is used when there isn’t enough hardware support for LRU?
Reference bits, associated with each page table entry and set by hw when page is referenced. All bits cleared periodically.
Identifies pages used since bits were last cleared.
What is the drawback of reference bits?
Can’t tell what order pages were used in.