Readings and References. Virtual Memory. Virtual Memory. Virtual Memory VPN. Reading. CSE Computer Systems December 5, 2001.

Similar documents
!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

Virtual Memory. Virtual Memory. Demand Paging. valid-invalid bit. Virtual Memory Larger than Physical Memory

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 15: Caching: Demand Paged Virtual Memory

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Address spaces and memory management

Paging algorithms. CS 241 February 10, Copyright : University of Illinois CS 241 Staff 1

Virtual Memory. Reading: Silberschatz chapter 10 Reading: Stallings. chapter 8 EEL 358

Operating System Concepts

Basic Page Replacement

Last Class: Demand Paged Virtual Memory

Page 1. Goals for Today" TLB organization" CS162 Operating Systems and Systems Programming Lecture 11. Page Allocation and Replacement"

a process may be swapped in and out of main memory such that it occupies different regions

CS370 Operating Systems

Chapter 9: Virtual-Memory

Virtual Memory. Chapter 8

CS162 Operating Systems and Systems Programming Lecture 11 Page Allocation and Replacement"

CS370 Operating Systems

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

Virtual Memory III. Jo, Heeseung

Chapter 8: Virtual Memory. Operating System Concepts

Chapter 4 Memory Management

ECE7995 Caching and Prefetching Techniques in Computer Systems. Lecture 8: Buffer Cache in Main Memory (I)

Operating Systems (1DT020 & 1TT802) Lecture 9 Memory Management : Demand paging & page replacement. Léon Mugwaneza

Virtual Memory. User memory model so far:! In reality they share the same memory space! Separate Instruction and Data memory!!

Page Replacement Algorithms

Lecture 12: Demand Paging

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

All Paging Schemes Depend on Locality. VM Page Replacement. Paging. Demand Paging

MEMORY: SWAPPING. Shivaram Venkataraman CS 537, Spring 2019

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is.

Chapter 8 Virtual Memory

3/3/2014! Anthony D. Joseph!!CS162! UCB Spring 2014!

Operating Systems CSE 410, Spring Virtual Memory. Stephen Wagner Michigan State University

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

Lecture 21: Virtual Memory. Spring 2018 Jason Tang

CS370 Operating Systems

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

Chapter 9: Virtual Memory

Virtual Memory Management

CS 333 Introduction to Operating Systems. Class 11 Virtual Memory (1) Jonathan Walpole Computer Science Portland State University

CS 153 Design of Operating Systems Winter 2016

Operating Systems. Overview Virtual memory part 2. Page replacement algorithms. Lecture 7 Memory management 3: Virtual memory

Basic Memory Management

1. Creates the illusion of an address space much larger than the physical memory

Virtual Memory Outline

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

How to create a process? What does process look like?

The Virtual Memory Abstraction. Memory Management. Address spaces: Physical and Virtual. Address Translation

CSE 153 Design of Operating Systems

COMP 346 WINTER 2018 MEMORY MANAGEMENT (VIRTUAL MEMORY)

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)

Chapters 9 & 10: Memory Management and Virtual Memory

Memory - Paging. Copyright : University of Illinois CS 241 Staff 1

Virtual Memory - II. Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - XVI. University at Buffalo.

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Lecture #15: Translation, protection, sharing

21 Lecture: More VM Announcements From last time: Virtual Memory (Fotheringham, 1961)

CS450/550 Operating Systems

Memory management, part 2: outline. Operating Systems, 2017, Danny Hendler and Amnon Meisels

Chapter 4: Memory Management. Part 1: Mechanisms for Managing Memory

Memory: Paging System

Reminder: Mechanics of address translation. Paged virtual memory. Reminder: Page Table Entries (PTEs) Demand paging. Page faults

Operating Systems Virtual Memory. Lecture 11 Michael O Boyle

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

Memory Hierarchy. Goal: Fast, unlimited storage at a reasonable cost per bit.

Chapter 9: Virtual Memory. Chapter 9: Virtual Memory. Objectives. Background. Virtual-address address Space

Memory Management Virtual Memory

Chapter 8: Main Memory. Operating System Concepts 9 th Edition

Memory management, part 2: outline

Today. Adding Memory Does adding memory always reduce the number of page faults? FIFO: Adding Memory with LRU. Last Class: Demand Paged Virtual Memory

Chapter 9: Virtual Memory

Chapter 4 Memory Management. Memory Management

VIRTUAL MEMORY READING: CHAPTER 9

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization

Memory Management Prof. James L. Frankel Harvard University

Chapter 8: Main Memory

Last Class. Demand Paged Virtual Memory. Today: Demand Paged Virtual Memory. Demand Paged Virtual Memory

CS399 New Beginnings. Jonathan Walpole

CS 550 Operating Systems Spring Memory Management: Page Replacement

Virtual Memory 1. Virtual Memory

Virtual Memory 1. Virtual Memory

Chapter 3 Memory Management: Virtual Memory

Virtual Memory. Today.! Virtual memory! Page replacement algorithms! Modeling page replacement algorithms

Swapping. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory. Demand Paging

Swapping. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CS370 Operating Systems

Course: Operating Systems Instructor: M Umair. M Umair

Operating Systems. Operating Systems Sina Meraji U of T

Lecture#16: VM, thrashing, Replacement, Cache state

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 10: Virtual Memory

Chapter 3 - Memory Management

Paging and Page Replacement Algorithms

Chapter 8 Virtual Memory

Transcription:

Readings and References Virtual Memory Reading Chapter through.., Operating System Concepts, Silberschatz, Galvin, and Gagne CSE - Computer Systems December, Other References Chapter, Inside Microsoft Windows, Third Edition, Solomon and Russinovich -Dec- CSE - Virtual Memory Virtual Memory Virtual paging to disk manage as though we always had enough if more is needed, use disk as backup storage Demand Paging load program pages in to as needed Another level of the storage hierarchy Main is a cache Disk space is the backing store -Dec- CSE - Virtual Memory Page table entry can point to a PPN or a location on disk (offset into ) A page on disk is swapped back in when it is referenced page fault Virtual Memory -Dec- CSE - Virtual Memory

Demand Paging As a program runs, the pages that it needs may or may not be in when it needs them if in, execution proceeds if not in, page is read in from disk and stored in If desired address is not in, the result is a page fault -Dec- CSE - Virtual Memory A reference to location X MMU: Is X's in the Translation Lookaside Buffer? Yes => get data from cache or. Done. No => Trap to OS to load X's /PPN into the TLB OS: Is X's VP actually in physical? Yes => replace a TLB entry with X's /PPN. Return control to original thread and restart instruction. Done. No => must load the VP from disk OS: replace a current page in with X s page from disk pick a page to replace, write it back to disk if dirty load X's VP from disk into physical Replace the TLB entry with X's /PPN. Return control to original thread and restart instruction. Done! -Dec- CSE - Virtual Memory Reference to causes a page fault because it is not in. Page Fault Example PPN has not been used recently. Write it to the. Read from the into physical at PPN. Virtual Memory & Memory Caches Physical is a cache of the Many of the same concepts we learned with caches apply to virtual both work because of locality dirty bits prevent pages from always being written back Some implementation aspects are different Virtual Memory is usually fully associative with complex replacement algorithms because a page fault is so expensive ( at least one disk read is required ) -Dec- CSE - Virtual Memory

Replacement Algorithms FIFO - First In, First Out throw out the oldest page often throws out frequently used pages RANDOM - toss a random page works okay, but not good enough OPT or MIN - toss the one you won t need pick page that won't be used for the longest time provably optimal, but impossible to implement -Dec- CSE - Virtual Memory Approximations to MIN LRU - Least Recently Used remember temporal locality? if we have used a page recently, we probably will use it again in the near future LRU is hard to implement exactly since there is significant record keeping overhead CLOCK - approximation of LRU and LRU is an approximation of MIN -Dec- CSE - Virtual Memory Perfect LRU Least Recently Used timestamp each page on every reference on page fault, find oldest page can keep a queue ordered by time of reference but that requires updating the queue every reference too much overhead per reference -Dec- CSE - Virtual Memory LRU Approximation: Clock Clock algorithm replace an old page, not necessarily the oldest page Keep a reference bit for every physical page hardware sets the bit on every reference bit isn't set => page not used since bit last cleared Maintain a next victim pointer can think of it as a clock hand, iterating over the collection of physical pages -Dec- CSE - Virtual Memory

On page fault Tick, tick,... advance the victim pointer to the next page check state of the reference bit If used, clear the bit and go to next page this page has been used since the last time we looked. Clear the usage indicator and move on. If not used, select this page as the victim this page has not been used since we last looked replace it with a new page from disk -Dec- CSE - Virtual Memory advance; PPN has been used; clear and advance Find a victim PPN has been not been used; replace and set use bit PPN has been used; clear and advance PPN has been used; clear and advance Clock Questions Thrashing Will Clock always find a page to replace? at worst it will clear all the reference bits, finally coming around to the oldest page If the hand is moving slowly? not many page faults If the hand is moving quickly? many page faults lots of reference bits set -Dec- CSE - Virtual Memory Thrashing occurs when pages are tossed out, but are needed again right away listen to the hard drive grind Example: a program touches pages often but only physical pages throughput What happens to performance? enough ns/ref (most refs hit in cache) not enough ms/ref (page faults every few instructions) Very common with shared machines number of processes -Dec- CSE - Virtual Memory

Thrashing Solutions If one job causes thrashing rewrite program to have better locality of reference If multiple jobs cause thrashing only run as many processes as can fit in Big red button swap out some hogs entirely Buy more -Dec- CSE - Virtual Memory Working Set The working set of a process is the set of pages that it is actually using set of pages a job has used in the last T seconds usually much smaller than the amount it might use If working set fits in process won't thrash Why do we adjust the working set size? too big => inefficient because programs keep pages in that they are not using very often too small => thrashing results because programs are losing pages that they are about to use -Dec- CSE - Virtual Memory WinK Memory Management WK Working Set WinK Pro/Server/DataCenter can manage to GB physical Virtual address is GB user, GB system Some services of manager allocate / free virtual share between processes map large files into lock pages in -Dec- CSE - Virtual Memory Subset of virtual pages resident in physical is the current working set WK allows working set to grow demand paging causes read from disk reads in clusters of pages on a fault - pages for code, pages for data Working set is trimmed as necessary using version of the clock algorithm -Dec- CSE - Virtual Memory

Managing allocations A process reserves address space tell the OS that we will need this space OS builds Virtual Address Descriptors but does not build page tables then commits pages in the address space room exists for the pages in or on disk OS builds page table for committed page when a page fault occurs -Dec- CSE - Virtual Memory Example: Stack Allocation Stack area is reserved when thread starts generally MB, although this can be changed at thread creation or with a linker switch Just one page of KB is committed the following page is marked PAGE_GUARD if page fault, then one more page is committed and the stack is allowed to grow another KB until it happens again -Dec- CSE - Virtual Memory Total committed greater than installed physical installed Virtual Address Descriptors binary tree of descriptors stores information about the reserved range of addresses Range: -FFFF Protect: R/W Inherit: Yes currently committed Range: -FFFF Protect: Read Only Inherit: No Range: E-F Protect: Copy-on-write Inherit: Yes physical plus -Dec- CSE - Virtual Memory

Two-level Page Tables Shared Memory -bit virtual address Page directory index Page table index byte offset bits bits bits table # Page Directory ( entries) PFN Page Tables ( entries per table) KB page Physical Memory Section Objects or file mapping objects Map portion of address space to common physical pages generally backed up with paging to disk backed - shared data file backed - mapped file, can be shared -Dec- CSE - Virtual Memory GB Address Windowing Extensions AWE mapping What do you do when GB is too small? GB Allocate huge chunks of physical OS Designate some virtual pages that are a window into that physical GB Remap the virtual pages to point to different parts of the physical as needed App AWE window Useful for large database applications, etc -Dec- CSE - Virtual Memory Server Application Virtual Address Space Physical Memory