1 / 18

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory. Adapted by Donghui Zhang from the original version by Silberschatz et al. Chapter 9: Virtual Memory. Why VM Demand Paging Page Fault Copy-on-Write Page Replacement. Why VM?. Only part of the program needs to be in memory for execution

taite
Download Presentation

Chapter 9: Virtual Memory

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 9: Virtual Memory Adapted by Donghui Zhang from the original version by Silberschatz et al.

  2. Chapter 9: Virtual Memory • Why VM • Demand Paging • Page Fault • Copy-on-Write • Page Replacement

  3. Why VM? • Only part of the program needs to be in memory for execution • Logical address space can therefore be much larger than physical address space • Allows for more efficient process creation

  4. Virtual Memory That is Larger Than Physical Memory

  5. Demand Paging • Bring a page into memory only when it is needed • Less I/O needed • Less memory needed • Faster response • More users • Page is needed  reference to it • invalid reference  abort • not-in-memory  bring to memory

  6. Valid-Invalid Bit • With each page table entry a valid–invalid bit is associated(v in-memory,i  not-in-memory) • Initially valid–invalid bit is set to i on all entries • Example of a page table snapshot: • During address translation, if valid–invalid bit in page table entry is I  page fault Frame # valid-invalid bit v v v v i …. i i page table

  7. Page Table When Some Pages Are Not in Main Memory

  8. Page Fault • If there is a reference to a page, first reference to that page will trap to operating system: page fault • Operating system looks at another table to decide: • Invalid reference  abort • Just not in memory • Get empty frame • Swap page into frame • Reset tables • Set validation bit = v • Restart the instruction that caused the page fault

  9. Steps in Handling a Page Fault

  10. page fault service time Performance of Demand Paging • Page Fault Rate 0  p  1.0 • if p = 0 no page faults • if p = 1, every reference is a fault • Effective Access Time (EAT) EAT = (1 – p) x memory access + p x ( page fault overhead + swap page out + swap page in + restart overhead )

  11. Demand Paging Example • Memory access time = 200 nanoseconds • Average page-fault service time = 8 milliseconds • EAT = (1 – p) x 200 + p x (8 milliseconds) = (1 – p) x 200 + p x 8,000,000 = 200 + p x 7,999,800 • If one access out of 1,000 causes a page fault, then EAT = 8.2 microseconds. This is a slowdown by a factor of 40!! 1 s = 1000 milli s 1 milli s = 1000 micro s 1 micro s = 1000 nano s

  12. Copy-on-Write • Copy-on-Write (COW) allows both parent and child processes to initially share the same pages in memoryIf either process modifies a shared page, only then is the page copied • COW allows more efficient process creation as only modified pages are copied

  13. Before Process 1 Modifies Page C After the modification, a new copy of Page C is generated for process 1.

  14. What happens if there is no free frame? • Page replacement – find some page in memory, but not really in use, swap it out! • Which one? • FIFO/LIFO • LRU/MRU • LFU/MFU • Side note: should keep a dirty bit for each frame.

  15. Basic Page Replacement • Find the location of the desired page on disk • Find a free frame: - If there is a free frame, use it - If there is no free frame, use a page replacement algorithm to select a victim frame • Bring the desired page into the (newly) free frame; update the page and frame tables • Restart the process

  16. Page Replacement Algorithms • Want lowest page-fault rate • Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string • In all our examples, the reference string is 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

  17. Page Replacement Algorithms • FIFO – First In First Out • LRU – Least Recently Used • LFU – Least Frequently Used • LIFO – Last In First Out • MRU – Most Recently Used • MFU – Most Frequently Used 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

  18. End of Chapter 9

More Related