CS139-lecture-20211123

Virtual memory cont. #

Page replacement algorithms cont. #

Recall:

  • FIFO looks at the time the page was initially brought in
  • LRU looks at the last time the page was accessed

Implementing LRU (least recently used)

image_2021-11-23-13-47-24

  • counter implementation has an exhaustive search, so \( \Theta(n) \) runtime
  • stack implementation has the least recently used at the bottom of the stack, each update is expensive because items are moved to the top of the stack when replaced

image_2021-11-23-13-50-03 image_2021-11-23-13-53-44

  • circles indicate page fault
  • top shows 3 frame memory, bottom shows 4 frame memory, for comparison

image_2021-11-23-13-56-06 image_2021-11-23-13-56-11 image_2021-11-23-13-55-51 image_2021-11-23-13-56-21 image_2021-11-23-13-56-29

  • second chance is like a warning before an eviction