COMP 3000 2011 Week 10 Notes

From Soma-notes

Virtual Memory

Virtual Memory: memory management technique; made of 32 bits divided into a 20 bit frame number and 12 bit offset that maps perfectly to a physical offset

32 bit address: first 20 bits of the address is the frame number with the lower 12 bits specifying the offset within that frame

Physical Memory: divided into frames where each frame is 4K--note that each page is also 4K meaning that any page can fit in any frame (solves fragmentation problem)

TLB: mapping virtual addresses to corresponding physical ones--this is done by mapping the 20 bit frame numbers, located in the first 20 bits of a 32 bit address, to each other.

Page Table: all virtual -> physical mappings are stored in the page table; when constructing a page table, a broad flat tree is desired (a good out degree for this is 1024). Page tables make use of the 4K structure of the system by having 1024 page table entries of 32 bits, which will make 4K bits.

PTE: page table entries, made of 32 bits in most archives.

Managing Memory

LRU: least recently used--the least recently used page will get kicked out of memory

Disk Cache: cache of files on disk--the problem is figuring out what memory to evict first. The memory you can usually evict first is:

  1. Memory that is already written to disk
  2. Files and program binaries as they are already synced to disk

Other memory that is safe to evict is memory that has both the dirty bit and the accessed bit flipped to 0.

  • Dirty Bit: if what is in memory is only a copy, meaning that, if the page is kicked out of memory, there is no memory loss, the dirty bit is flipped to 0
  • Accessed Bit: has the memory this bit pertains to been accessed or not? A clock algorithm runs routinely and sets the access bit of all memory to zero. Next time the algorithm goes through,if you see a 1 somewhere, the memory has been accessed since the last sweep, meaning we should keep it. However, if somewhere still has a 0, it means that the memory has not been accessed since the last sweep