vm - Virtual Memory Last Week Memory Management •...

Info icon This preview shows pages 1–12. Sign up to view the full content.

Virtual Memory
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

2 Last Week Memory Management Increase degree of multiprogramming Entire process needs to fit into memory Dynamic Linking and Loading Swapping Contiguous Memory Allocation Dynamic storage memory allocation problem First-fit, best-fit, worst-fit Fragmentation - external and internal Paging Structure of the Page Table Segmentation
Image of page 2
3 Goals for Today Virtual memory How does it work? Page faults Resuming after page faults When to fetch? What to replace? Page replacement algorithms FIFO, OPT, LRU (Clock) Page Buffering Allocating Pages to processes
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

4 What is virtual memory? Each process has illusion of large address space 2 32 for 32-bit addressing However, physical memory is much smaller How do we give this illusion to multiple processes? Virtual Memory: some addresses reside in disk page table Physical memory disk Virtual memory page 0 page 1 page 2 page 3 page 4 page N
Image of page 4
5 Virtual memory Separates users logical memory from physical memory. 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 address spaces to be shared by several processes Allows for more efficient process creation
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

6 Virtual Memory Load entire process in memory (swapping), run it, exit Is slow (for big processes) Wasteful (might not require everything) Solutions: partial residency Paging: only bring in pages, not all pages of process Demand paging: bring only pages that are required Where to fetch page from? Have a contiguous space in disk: swap file (pagefile.sys)
Image of page 6
7 How does VM work? Modify Page Tables with another bit (“is present”) If page in memory, is_present = 1 , else is_present = 0 If page is in memory, translation works as before If page is not in memory, translation causes a page fault Disk Mem 32 :P=1 4183 :P=0 177 :P=1 5721 :P=0 Page Table 0 1 2 3
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

8 Page Faults On a page fault: OS finds a free frame, or evicts one from memory (which one?) Want knowledge of the future? Issues disk request to fetch data for page (what to fetch?) Just the requested page, or more? Block current process, context switch to new process (how?) Process might be executing an instruction When disk completes, set present bit to 1, and current process in ready queue
Image of page 8
9 Steps in Handling a Page Fault
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

10 Resuming after a page fault Should be able to restart the instruction For RISC processors this is simple: Instructions are idempotent until references are done More complicated for CISC: E.g. move 256 bytes from one location to another Possible Solutions: Ensure pages are in memory before the instruction executes
Image of page 10
11 When to fetch?
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern