VM Design Issues Vivek Pai / Kai Li Princeton University.

Slides:



Advertisements
Similar presentations
Chapter 4 Memory Management Basic memory management Swapping
Advertisements

Page Replacement Algorithms
Chapter 11 – Virtual Memory Management
Virtual Memory 3 Fred Kuhns
Module 10: Virtual Memory
Chapter 3 Memory Management
Chapter 10: Virtual Memory
Chapter 11 – Virtual Memory Management
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Virtual Memory (II) CSCI 444/544 Operating Systems Fall 2008.
Memory Management.
Paging: Design Issues. Readings r Silbershatz et al: ,
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
9: Virtual Memory1 Jerry Breecher OPERATING SYSTEMS VIRTUAL MEMORY.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 36 Virtual Memory Read.
1 Virtual Memory Management B.Ramamurthy. 2 Demand Paging Main memory LAS 0 LAS 1 LAS 2 (Physical Address Space -PAS) LAS - Logical Address.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
1 Virtual Memory in the Real World Implementing exact LRU Approximating LRU Hardware Support Clock Algorithm Thrashing Cause Working Set.
1 Virtual Memory vs. Physical Memory So far, all of a job’s virtual address space must be in physical memory However, many parts of programs are never.
Competing For Memory Vivek Pai / Kai Li Princeton University.
VM Design Issues Vivek Pai / Kai Li Princeton University.
Paging Algorithms Vivek Pai / Kai Li Princeton University.
Virtual Memory and Paging J. Nelson Amaral. Large Data Sets Size of address space: – 32-bit machines: 2 32 = 4 GB – 64-bit machines: 2 64 = a huge number.
Virtual Memory Management B.Ramamurthy. Paging (2) The relation between virtual addresses and physical memory addres- ses given by page table.
1 Virtual Memory Management B.Ramamurthy Chapter 10.
OS Spring’04 Virtual Memory: Page Replacement Operating Systems Spring 2004.
Page Replacement Algorithms
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Operating Systems ECE344 Ding Yuan Page Replacement Lecture 9: Page Replacement.
Page 19/17/2015 CSE 30341: Operating Systems Principles Optimal Algorithm  Replace page that will not be used for longest period of time  Used for measuring.
Virtual Memory CS Introduction to Operating Systems.
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Paging.
Operating Systems CMPSC 473 Virtual Memory Management (3) November – Lecture 20 Instructor: Bhuvan Urgaonkar.
Lecture 11 Page 1 CS 111 Online Working Sets Give each running process an allocation of page frames matched to its needs How do we know what its needs.
Lecture 11 Page 1 CS 111 Online Virtual Memory A generalization of what demand paging allows A form of memory where the system provides a useful abstraction.
CS 3204 Operating Systems Godmar Back Lecture 21.
Lecture Topics: 11/24 Sharing Pages Demand Paging (and alternative) Page Replacement –optimal algorithm –implementable algorithms.
CS307 Operating Systems Virtual Memory Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
1 Virtual Memory. Cache memory: provides illusion of very high speed Virtual memory: provides illusion of very large size Main memory: reasonable cost,
Virtual Memory Questions answered in this lecture: How to run process when not enough physical memory? When should a page be moved from disk to memory?
CSE 153 Design of Operating Systems Winter 2015 Lecture 12: Page Replacement.
NETW3005 Virtual Memory. Reading For this lecture, you should have read Chapter 9 (Sections 1-7). NETW3005 (Operating Systems) Lecture 08 - Virtual Memory2.
LECTURE 12 Virtual Memory. VIRTUAL MEMORY Just as a cache can provide fast, easy access to recently-used code and data, main memory acts as a “cache”
10.1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples.
Operating Systems ECE344 Ding Yuan Page Replacement Lecture 9: Page Replacement.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
COS 318: Operating Systems Virtual Memory Paging.
CS 333 Introduction to Operating Systems Class 14 – Page Replacement
Lecture 12 Virtual Memory.
Chapter 9: Virtual Memory – Part I
CSE 120 Principles of Operating
Lecture 28: Virtual Memory-Address Translation
Chapter 9: Virtual-Memory Management
What Happens if There is no Free Frame?
Demand Paged Virtual Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
Contents Memory types & memory hierarchy Virtual memory (VM)
CSE451 Virtual Memory Paging Autumn 2002
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Operating Systems CMPSC 473
Virtual Memory: Working Sets
Virtual Memory: Policies (Part II)
Lecture 9: Caching and Demand-Paged Virtual Memory
CSE 153 Design of Operating Systems Winter 19
Presentation transcript:

VM Design Issues Vivek Pai / Kai Li Princeton University

2 Mini-Gedankenexperimenten What’s the refresh rate of your monitor? What is the access time of a hard drive? What response time determines sluggishness or speediness? What’s the relation? What determines the running speed of a program that’s paging heavily? If you have a program that pages heavily, what are your options to improve the situation?

3 Mechanics The midterm was probably too long Haven’t looked closely at them Grading based on mean, std deviation Almost lost a lecture – today’s Already had some post-midterm slack I’ll adjust the web page appropriately Project client updated – maybe use it

4 Where We Left Off Last Time Various approaches to evicting pages Some discussion about why doing even “well” is hard to implement Belady’s algorithm for off-line analysis

5 The Big Picture We’ve talked about single evictions Most computers are multiprogrammed Single eviction decision still needed New concern – allocating resources How to be “fair enough” and achieve good overall throughput This is a competitive world – local and global resource allocation decisions

6 x86 Page Table Entry Valid Writable Owner (user/kernel) Write-through Cache disabled Accessed (referenced) Dirty PDE maps 4MB Global Page frame numberDLGlCwPUACdWtOWV Reserved 31 12

7 Program Behaviors 80/20 rule > 80% memory references are made by < 20% of code Locality Spatial and temporal Working set Keep a set of pages in memory would avoid a lot of page faults # pages in memory # page faults Working set

8 Observations re Working Set Working set isn’t static There often isn’t a single “working set” Multiple plateaus in previous curve Program coding style affects working set Working set is hard to gauge What’s the working set of an interactive program?

9 Working Set Main idea Keep the working set in memory An algorithm On a page fault, scan through all pages of the process If the reference bit is 1, record the current time for the page If the reference bit is 0, check the “last use time” If the page has not been used within , replace the page Otherwise, go to the next Add the faulting page to the working set

10 WSClock Paging Algorithm Follow the clock hand If the reference bit is 1, set reference bit to 0, set the current time for the page and go to the next If the reference bit is 0, check “last use time” If page has been used within , go to the next If page hasn’t been used within  and modify bit is 1 Schedule the page for page out and go to the next If page hasn’t been used within  and modified bit is 0 Replace this page

11 Simulating Modify Bit with Access Bits Set pages read-only if they are read-write Use a reserved bit to remember if the page is really read-only On a read fault If it is not really read-only, then record a modify in the data structure and change it to read-write Restart the instruction

12 Implementing LRU without Reference Bit Some machines have no reference bit VAX, for example Use the valid bit or access bit to simulate Invalidate all valid bits (even they are valid) Use a reserved bit to remember if a page is really valid On a page fault If it is a valid reference, set the valid bit and place the page in the LRU list If it is a invalid reference, do the page replacement Restart the faulting instruction

13 Demand Paging Pure demand paging relies only on faults to bring in pages Problems? Possibly lots of faults at startup Ignores spatial locality Remedies Loading groups of pages per fault Prefetching/preloading

14 Speed and Sluggishness Slow is >.1 seconds (100 ms) Speedy is <<.1 seconds Monitors tend to be 60+ Hz = <16.7ms between screen paints Disks have seek + rotational delay Seek is somewhere between 7-16 ms At 7200rpm, one rotation = 1/120 sec = 8ms. Half-rotation is 4ms Conclusion? One disk access OK, six are bad

15 Disk Address Use physical memory as a cache for disk Where to find a page on a page fault? PPage# field is a disk address Virtual address space invalid Physical memory

16 Imagine a Global LRU Global – across all processes Idea – when a page is needed, pick the oldest page in the system Problems? Process mixes? Interactive processes Active large-memory sweep processes Mitigating damage?

17 Amdahl’s Law Gene Amdahl (IBM, then Amdahl) Noticed the bottlenecks to speedup Assume speedup affects one component New time = (1-not affected) + affected/speedup In other words, diminishing returns

18 NT x86 Virtual Address Space Layouts FFFFFFF System cache Paged pool Nonpaged pool Kernel & exec HAL Boot drivers Process page tables Hyperspace Application code Globals Per-thread stacks DLL code 3-GB user space 1-GB system space BFFFFFFF C FFFFFFFF C C

19 Virtual Address Space in Win95 and Win FFFFFFF Operating system (Ring 0 components) Shared, process-writable (DLLs, shared memory, Win16 applications) Win95 and Win98 User accessible FFFFFFFF C Unique per process (per application), user mode Systemwide user mode Systemwide kernel mode

20 Details with VM Management Create a process’s virtual address space Allocate page table entries (reserve in NT) Allocate backing store space (commit in NT) Put related info into PCB Destroy a virtual address space Deallocate all disk pages (decommit in NT) Deallocate all page table entries (release in NT) Deallocate all page frames

21 Page States (NT) Active: Part of a working set and a PTE points to it Transition: I/O in progress (not in any working sets) Standby: Was in a working set, but removed. A PTE points to it, not modified and invalid. Modified: Was in a working set, but removed. A PTE points to it, modified and invalid. Modified no write: Same as modified but no write back Free: Free with non-zero content Zeroed: Free with zero content Bad: hardware errors

22 Working set replacement Page in or allocation Demand zero fault Dynamics in NT VM Process working set Standby list Modified list Modified writer “Soft” faults Free list Zero thread Zero list Bad list

23 Shared Memory How to destroy a virtual address space? Link all PTEs Reference count How to swap out/in? Link all PTEs Operation on all entries How to pin/unpin? Link all PTEs Reference count Process 1 Process 2 w w Page table Physical pages

Copy-On-Write Child’s virtual address space uses the same page mapping as parent’s Make all pages read-only Make child process ready On a read, nothing happens On a write, generates an access fault map to a new page frame copy the page over restart the instruction Parent process Child process r r r r Page table Physical pages

25 Issues of Copy-On-Write How to destroy an address space Same as shared memory case? How to swap in/out? Same as shared memory How to pin/unpin Same as shared memory