170 likes | 324 Views
Paged Virtual Memory Management (VMM). Tyler Fetters 11.21.2012 CS201 – Systems Programming. Outline. Warm Up Question Define VMM Memory Layout and Costs VMM Parable Vocabulary History of VMM Reason for VMM VMM implementation Summary. To run slow or not to run at all?
E N D
Paged Virtual Memory Management (VMM) Tyler Fetters 11.21.2012 CS201 – Systems Programming
Outline • Warm Up Question • Define VMM • Memory Layout and Costs • VMM Parable • Vocabulary • History of VMM • Reason for VMM • VMM implementation • Summary To run slow or not to run at all? That is the question….
Warm Up Question • 32-bit architecture, byte-addressable, 4-byte words, 4kB page size • Two-level paging mechanism, consisting of Page Directory and Page Tables in addition to user pages • How many Bits are Required for any page address? • Answer 20 Bits (PD and PT need 10 + 10 ) • How many Page Tables are possible? • 1024 Total Entries • How many Total User Pages can exist? • 1,048,576 Pages • True or False: There may be unused bits within the Page Directory and/or Page Table(s) • True, there are 12 other bits which can be used for additional information similar to cache overhead (example dirty bit)
Define VMM • According to Herb Mayer (Abbreviated): • Paged VMM is process of memory areas relocated out to disk, while other areas moved back from disc into memory on demand. • This relocation in and out, called swapping, can be handled transparently (often by the OS), thus imposing no additional burden on the application programmer. • The system must detect situations in which an address references an object that is on disk and must therefore perform the hidden swap-in automatically. • Paged VMM trades speed for address range. • Caused by mapping logical-to-physical • Slow disk accesses. • Can be 100s of 1000s to millions of times more than a memory access. • The exchange is enabling memory-hungry programs to run slowly vs. not executing at all.
Mac and Cheese • Problem: you’re a broke college student and always hungry • Solution: Mac and Cheese is both delicious and affordable • Process: • Boil Water, Cook the pasta, strain water… • Add Milk and Butter… • Problem: you don’t have any Milk • Option one: Go to sleep Hungry • Option two: VMM like solution • Go to the grocery store and buy milk • Cost: Additional time taken to make meal • Advantage: Eat, Drink (Milk) and be Happy
Vocabulary • Virtual Memory: Memory management policy that separates physical from logical memory. In particular, virtual memory can create the impression that a larger amount of memory is addressable than is really available on the target. • Physical Memory: Main memory actually available physically to a processor. Antonym: Logical memory. • Resident: Attribute of a page (or of any memory object) referenced by executing code: Object is physically in memory, then it is resident, or is not in memory, then it is non-resident.
Vocabulary • Page Frame: A portion of physical memory that is aligned and fixed in size able to hold one page. It starts at a boundary evenly divisible by the page size. Total physical memory should be an integral multiple of the page size. Logical memory is an integral multiple of page size by definition. • Page Table: A list of addresses of user Pages. Typically each page table consumes an integral number of pages, e.g. 1. In addition to page addresses, each entry also contains information about presence, access rights, dirty, global, etc. similar to Page Directory entries. • Page Directory: A list of addresses for Page Tables. Typically this directory consumes an integral number of pages as well, e.g. 1 page. In addition to page table addresses, each entry also contains information about presence, access rights, written to or not, global, etc. similar to Page Table entries.
Vocabulary • Swap-in: Transfer of a page of information from secondary storage to primary storage (into a page frame in memory); from disk to physical memory. • Swap-out: Transfer of a page of information from primary to secondary storage; from physical memory to disk. • Thrashing: Excessive amount of swapping. When this happens, performance is severely degraded. This is an indicator for the working set being too small. • Working Set: That number of allocated physical page frames to guarantee that the program executes without thrashing. Working set is unique for any piece of software; moreover varies by the input data for a particular execution of such a piece of SW.
1970 • 1980 • 1990 • 2000 Time Line History • Just when VMM was falling into disfavor, the addressing limitation of 32 bits started to constrain real programs. In the early 1990, 64-bit architectures started becoming common-place, rather than an exception • Insufficient memories were common and were one aspect of the growing Software Crisis of the late 1970s • Invented about 1960 at University of Manchester for Atlas Computer • 980 • By mid 1980s, memories became cheaper, faster. • Late 1980s, memories had become cheaper yet, the address range remained 32-bit, and large physical memories became possible and available • 1990s, 64-bit addresses were common, 64-bit integer arithmetic was generally performed in hardware, no longer via slow library extensions • In the late 1960s to early 1980s, memory was expensive, processors were expensive and getting fast, and programs grew large.
Reason and Goals for VMM • Make full logical (virtual) address space available, even if smaller physical memory installed • Perform mapping transparently. Thus, if at a later time the target receives a larger physical memory, the same program will run unchanged except faster • Implement the mapping in a way that the overhead is small in relation to the total program execution
Summary • Warm Up Question • Define VMM • Memory Layout and Costs • VMM Parable • Vocabulary • History of VMM • Reason for VMM • VMM implementation
References • Mayer, Herb: October 2011, “Paged Virtual Memory Management (VMM)” Lecture Notes CS201, Portland State University • Denning, Peter: 1968, “The Working Set Model for Program Behavior”, ACM Symposium on Operating Systems Principles, Vol 11, Number 5, May 1968, pp 323-333. • Organick, Elliott I. (1972). The Multics System: An Examination of Its Structure. MIT Press. • Alex Nichol, http://www.aumha.org/win5/a/xpvm.php Virtual Memory in Windows XP • Multics history: http://www.multicians.org/history.html • KDF6 development history: http://archive.computerhistory.org/resources/text/English_Electric/EnglishElectric.KDF9.1961.102641284.pdf • Bryant, Randal, O’Hallaron David. (2011). Computer Systems: A Programmer’s Perspective. Prentice Hall. • Virtual memory. (2012, November 12). In Wikipedia, The Free Encyclopedia. Retrieved 06:57, November 16, 2012, from http://en.wikipedia.org/w/index.php?title=Virtual_memory&oldid=522724534