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

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

View Full Document Right Arrow Icon
Virtual Memory
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background 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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background 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
Background image of page 5

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

View Full DocumentRight Arrow Icon
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)
Background 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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
9 Steps in Handling a Page Fault
Background image of page 9

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

View Full DocumentRight Arrow Icon
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
Background image of page 10
11 When to fetch? Just before the page is used!
Background image of page 11

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

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 65

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

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online