CS139-lecture-20211118

Memory cont. #

Page tables / addressing cont. #

image_2021-11-18-13-39-15 image_2021-11-18-13-54-00 image_2021-11-18-13-56-46 image_2021-11-18-13-59-53

  • the more hierarchy you have, the more memory accesses you need

image_2021-11-18-14-00-11 image_2021-11-18-14-00-16

Hashed page tables #

image_2021-11-18-14-04-41 image_2021-11-18-14-04-46

  • we can use either method of resolving collision in the hash table: chaining or linear probing

Inverted page table #

image_2021-11-18-14-09-34 image_2021-11-18-14-09-56

  • instead of keep track of logical pages, we keep track of physical pages
  • notice that we add a new field to the logical address: pid
  • a linear search is involved at worst case, so the page table can be improved by using a hash table

Virtual memory #

Memory for the point of view of the program.

image_2021-11-18-14-19-02 image_2021-11-18-14-19-07 image_2021-11-18-14-19-11

  • how can we run a program that will use more memory than totally available?
  • we’ll just load what is necessary

image_2021-11-18-14-22-54 image_2021-11-18-14-22-58

When to load a page? #

image_2021-11-18-14-23-05 image_2021-11-18-14-23-10 image_2021-11-18-14-24-21

  • pages with the invalid bit do not have a frame number

Page fault #

If there is a reference to a page, but it is not in memory, it causes a page fault.

image_2021-11-18-14-25-54 image_2021-11-18-14-26-25

Demand paging #

image_2021-11-18-14-32-39 image_2021-11-18-14-32-43

  • evicted pages go to swap, incase we need to bring it back soon
  • swap space can be in memory, or on hard drive

image_2021-11-18-14-33-43 image_2021-11-18-14-35-55

Page replacement algorithms #

image_2021-11-18-14-36-28 image_2021-11-18-14-36-48 image_2021-11-18-14-37-10

  • looks at when page was loaded, picks the oldest
  • implement with FIFO queue

image_2021-11-18-14-38-13

  • theoretically the best, but relies on knowing the future

image_2021-11-18-14-38-20 image_2021-11-18-14-40-16