Virtual Memory Flashcards
what is the motivation behind virtual memory?
- logical and physical addresses are completely separated
- processes address a virtual address space, which is larger than physical memory
- so programmers don’t have to be concerned with physical memory size
- more programs can run at the same time because they’re not fighting for space
- less I/O required to swap programs in and out of memory, increasing performance
- the entire program doesn’t have to be in memory
- allows shared memory
what is demand paging (basic concept)?
the entire program may not be needed when running. when using demand paging only the required pages are loaded into memory, as they are needed
what is a lazy swapper?
only swaps pages when they are needed
what is the purpose of the valid/invalid bit?
each entry in the page table has a flag bit that indicates if the page is in memory
if the process tries to access an invalid page, we trap to the OS in a page fault, which loads the page from disk and restarts
what the 5 steps in a page fault?
- check if address is legal
- find a free frame
- schedule disk read operation
- set the frame number and valid bit in the page table
- restart the instruction
what is pure demand paging? problems?
we dont have any pages in memory when we start execution, the first instruction triggers a page fault. pages are only loaded via page fault. restarting instructions can be expensive
how do we calculate the EAT in page faults?
p = probability of page fault ma = memory access time EAT = (1 - p) x ma + p x page fault time
what is the bottleneck in page faults?
disk reading because its mechanical, there’s competition
page faults REALLY slow things down
what is and wat are three strategies for handling over-allocation?
- terminate the process
- swap out a process entirely
- page replacement!
what is the page fault routine with replacement?
- find location of page on disk
- look for a free page frame
- if free, carry on
- if not, use a page replacement algorithm to select a victim
- copy victim to disk and mark as invalid
- read the page into the frame
downsides of page replacement? how to mitigate?
- 2 page transferes are neeeded, which increases our page fault time
- unmodified pages dont have to be written back, so we can use a dirty bit indicating wheter the page has been modified since it was faulted