Least Recently Used (LRU) Approximations - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

Least Recently Used (LRU) Approximations

Description:

Second Chance Algorithm. use a single ... Second Chance Algorithm. Pages are listed in a FIFO queue. Each page has a ... Second Chance FIFO. Best case ... – PowerPoint PPT presentation

Number of Views:154
Avg rating:3.0/5.0
Slides: 6
Provided by: csiS7
Category:

less

Transcript and Presenter's Notes

Title: Least Recently Used (LRU) Approximations


1
Least Recently Used (LRU) Approximations
  • Objective is to approximate Least Recently Used,
    as a predictor of future page use.
  • Useful ideas for virtual memory and caching
    both replace pages
  • Two Example Strategies
  • Reference Bits
  • use a set of bits to track the usage of a page,
    then make page replacement decisions based on the
    tracking data
  • Second Chance Algorithm
  • use a single bit to track usage

2
Reference Bits
  • Implemented in hardware
  • Uses a single bit to track recent access (per
    page)
  • Uses a set of reference bits to store access
    history (per page)
  • Every time a page is accessed, its accessed bit
    is set
  • Periodically, the access bit is merged with the
    reference bits
  • Shift reference bits to the right
  • Add access bit in high-order bit position
  • Reset the access bit
  • The reference bits can be used to decide which
    page has been least recently accessed.
  • High number is more recently access than low
    number

3
Second Chance Algorithm
  • Pages are listed in a FIFO queue
  • Each page has a single accessed bit
  • When need to swap out a page To find the page
    to replace
  • Start at top of list
  • If pages reference bit is set, skip this page
    (but reset the bit to zero)
  • If pages reference bit is reset, swap this page
  • If reached the bottom of the list
  • (all bits were set, but have now been reset),
  • start over at the top (and replace that one)

4
Examples on Board
  • Optimal
  • FIFO
  • Beladys Anomaly
  • LRU
  • Ref bits
  • Second Chance FIFO

5
Work?
  • The update of the reference bits can be done in
    hardware
  • But what about the selection process finding
    the LRU
  • Sequential search for ref bits? Order n O(n)
  • Store pages in a binary tree? Order logn
    O(logn) (base 2)
  • Second Chance FIFO
  • Best case first one checked
  • Worst case go around and start back at the top
    (n1)
  • Average expected about n/2
  • If n is large, then unacceptable
  • Next a parallel implementation
  • LRU reference bit compare by Self-Selection
Write a Comment
User Comments (0)
About PowerShow.com