Virtual Memory

  • CPU and OS translate virtual addresses to physical addresses
  • Initially designed so you don’t need to store your program and data separately
  • Now it is used for protection
    • Allows the OS to check that you have access to the certain physical address
    • For each address check base address bound

invert

Four Important Questions

  • Where to place a block in main memory?
    • Operating system takes care of it
    • Replacement takes very long because it is fully associative
  • How to find a block in main memory?
    • Page table is used
    • Offset is concatenated when paging is used
    • Offset is added when segmentation is used
  • Which block to replace when needed?
    • LRU is used to minimize page faults
  • What happens on write?
    • Always write back (use of dirty bit)
    • Because magnetic disks takes millions of cycles to access

Fast Address Calculation

  • Page tables are very large
    • Kept in main memory
  • Remember the last translation
    • Reuse if the address is on the same page
  • Exploit the principle of locality
    • If access have locality, the address translations also have locality
    • Keep the address translations in a cache
      • Translation lookaside buffer (TLB)
      • The tag part stores the virtual address and the data part stores the page number.

Addressing

  • We will cover paging
    • Intel uses segmenting for backwards compatibility invert
  • We have a table that translates between the virtual address and the paged address
    • This table grows as needed, because the whole table would be petabytes
      • It is also stored across levels of caches
      • Translation lookaside buffer
    • Along with the optimizations
      • Store the virtual address implicitly using index
      • Use inverted table (physical to virtual) because there are less physical addresses
  • While each process feels like it has access to all the memory, it is expected for them to not abuse that invert