1 / 92

Demand Paged Virtual Memory

Demand Paged Virtual Memory. Andy Wang Operating Systems COP 4610 / CGS 5765. Up to this point…. We assume that a process needs to load all of its address space before running e.g., 0x0 to 0xFFFFFFFF Observation: 90% of time is spent on 10% of code. Demand Paging.

Download Presentation

Demand Paged 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. Demand Paged Virtual Memory Andy Wang Operating Systems COP 4610 / CGS 5765

  2. Up to this point… • We assume that a process needs to load all of its address space before running • e.g., 0x0 to 0xFFFFFFFF • Observation: 90% of time is spent on 10% of code

  3. Demand Paging • Demand paging: allows pages that are referenced actively to be loaded into memory • Remaining pages stay on disk • Provides the illusion of infinite physical memory

  4. Demand Paging Mechanism • Page tables sometimes need to point to disk locations (as opposed to memory locations) • A table entry needs a present (valid) bit • Present means a page is in memory • Not present means that there is a page fault

  5. Page Fault • Hardware trap • OS performs the following steps while running other processes (analogy: firing and hiring someone) • Choose a page • If the page has been modified, write its contents to disk • Change the corresponding page table entry and TLB entry • Load new page into memory from disk • Update page table entry • Continue the thread

  6. Transparent Page Faults • Transparent (invisible) mechanisms • A process does not know how it happened • It needs to save the processor states and the faulting instruction

  7. More on Transparent Page Faults • An instruction may have side effects • Hardware needs to either unwind or finish off those side effects ld r1, x // page fault

  8. dest begin dest end More on Transparent Page Faults • Hardware designers need to understand virtual memory • Unwinding instructions not always possible • Example: block transfer instruction block trans source begin source end

  9. Page Replacement Policies • Random replacement: replace a random page + Easy to implement in hardware (e.g., TLB) - May toss out useful pages • First in, first out (FIFO): toss out the oldest page + Fair for all pages - May toss out pages that are heavily used

  10. More Page Replacement Policies • Optimal (MIN): replaces the page that will not be used for the longest time + Optimal - Does not know the future • Least-recently used (LRU): replaces the page that has not been used for the longest time + Good if past use predicts future use - Tricky to implement efficiently

  11. More Page Replacement Policies • Least frequently used (LFU): replaces the page that is used least often • Tracks usage count of pages + Good if past use predicts future use - Difficult to replace pages with high counts

  12. Example • A process makes references to 4 pages: A, B, E, and R • Reference stream: BEERBAREBEAR • Physical memory size: 3 pages

  13. FIFO

  14. FIFO

  15. FIFO

  16. FIFO

  17. FIFO

  18. FIFO

  19. FIFO

  20. FIFO

  21. FIFO

  22. FIFO

  23. FIFO

  24. FIFO

  25. FIFO

  26. FIFO

  27. FIFO

  28. FIFO

  29. FIFO • 7 page faults

  30. FIFO • 4 compulsory cache misses

  31. MIN

  32. MIN

  33. MIN

  34. MIN

  35. MIN

  36. MIN

  37. MIN

  38. MIN

  39. MIN

  40. MIN

  41. MIN

  42. MIN • 6 page faults

  43. LRU

  44. LRU

  45. LRU

  46. LRU

  47. LRU

  48. LRU

  49. LRU

  50. LRU

More Related