Virtual Memory Hakim Weatherspoon CS 3410 Computer Science

Slides:



Advertisements
Similar presentations
OS Memory Addressing.
Advertisements

1 A Real Problem  What if you wanted to run a program that needs more memory than you have?
Introduction to Operating Systems CS-2301 B-term Introduction to Operating Systems CS-2301, System Programming for Non-majors (Slides include materials.
CS 311 – Lecture 21 Outline Memory management in UNIX
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Virtual Memory 1 P & H Chapter 5.4 (up to TLBs)
CS 153 Design of Operating Systems Spring 2015
Chapter 10 – Virtual Memory Organization Outline 10.1 Introduction 10.2Virtual Memory: Basic Concepts 10.3Block Mapping 10.4Paging Paging Address.
Recap. The Memory Hierarchy Increasing distance from the processor in access time L1$ L2$ Main Memory Secondary Memory Processor (Relative) size of the.
CS 104 Introduction to Computer Science and Graphics Problems
Memory Management CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
9.9.2 Memory Placement Strategies Where to put incoming processes –First-fit strategy Process placed in first hole of sufficient size found Simple, low.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS 162 Discussion Section Week 1 (9/9 – 9/13) 1. Who am I? Kevin Klues Office Hours:
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Threads and Processes.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation.
Lecture 11 Page 1 CS 111 Online Memory Management: Paging and Virtual Memory CS 111 On-Line MS Program Operating Systems Peter Reiher.
PA0 due 60 hours. Lecture 4 Memory Management OSTEP Virtualization CPU: illusion of private CPU RAM: illusion of private memory Concurrency Persistence.
Operating Systems and Systems Programming CS162 Teaching Staff.
12/5/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam King,
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Hardware.
Operating Systems Unit 7: – Virtual Memory organization Operating Systems.
Virtual Memory 3 Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University P & H Chapter 5.4.
Logical & Physical Address Nihal Güngör. Logical Address In simplest terms, an address generated by the CPU is known as a logical address. Logical addresses.
Operating Systems Session 7: – Virtual Memory organization Operating Systems.
OS Memory Addressing. Architecture CPU – Processing units – Caches – Interrupt controllers – MMU Memory Interconnect North bridge South bridge PCI, etc.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Embedded Real-Time Systems
Main Memory CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
CS 162 Discussion Section Week 2. Who am I? Prashanth Mohan Office Hours: 11-12pm Tu W at.
Vivek Seshadri 15740/18740 Computer Architecture
Virtual Memory Acknowledgment
Chapter 10: Computer systems (1)
Chapter 8: Main Memory.
CSE 120 Principles of Operating
CS703 - Advanced Operating Systems
Outline Paging Swapping and demand paging Virtual memory.
Virtual Memory Hakim Weatherspoon CS 3410, Spring 2013
Memory Hierarchy Virtual Memory, Address Translation
Instructors: Haryadi Gunawi
CS 286: Memory Paging and Virtual Memory
Operating System Concepts
Operating Systems and Systems Programming
Chapter 8: Main Memory.
CSCI206 - Computer Organization & Programming
Virtual Memory 3 Hakim Weatherspoon CS 3410, Spring 2011
The Operating System Memory Manager
Multistep Processing of a User Program
Virtual Memory Hakim Weatherspoon CS 3410, Spring 2012
CS399 New Beginnings Jonathan Walpole.
Memory Physical and Virtual
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Memory Management Overview
Prof. Hakim Weatherspoon
Virtual Memory Hardware
CSCE 313 – Introduction to UNIx process
Prof. Kavita Bala and Prof. Hakim Weatherspoon
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Chapter 8: Memory Management strategies
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Lecture 3: Main Memory.
CS 3410 Computer System Organization & Programming
Virtual Memory Lecture notes from MKP and S. Yalamanchili.
Virtual Memory Hakim Weatherspoon CS 3410 Computer Science
OPERATING SYSTEMS MEMORY MANAGEMENT BY DR.V.R.ELANGOVAN.
Light-Weight Process (Threads)
Cache writes and examples
CSE 542: Operating Systems
Page Main Memory.
Presentation transcript:

Virtual Memory Hakim Weatherspoon CS 3410 Computer Science Cornell University [Weatherspoon, Bala, Bracy, McKee, and Sirer]

Where are we now and where are we going? How many programs do you run at once? a) 1 b) 2 c) 3-5 d) 6-10 e) 11+

Big Picture: Multiple Processes How to run multiple processes? Time-multiplex a single CPU core (multi-tasking) Web browser, skype, office, … all must co-exist Many cores per processor (multi-core) or many processors (multi-processor) Multiple programs run simultaneously

Processor & Memory CPU address/data bus... … routed through caches … to main memory Simple, fast, but… CPU 0xfff…f 0x7ff…f Stack $$ Heap Data Text 0x000…0 Memory

Multiple Processes Q: What happens when another program is executed concurrently on another processor? CPU 0xfff…f 0x7ff…f Stack Stack $$ $$ Heap Heap CPU Data Data Text Text 0x000…0 Memory

Multiple Processes Q: Can we relocate second program? $$ $$ CPU CPU 0xfff…f 0x7ff…f Stack Stack $$ $$ Heap Heap CPU Data Data Text Text 0x000…0 Memory

Big Picture: (Virtual) Memory Process 1 3 2 1 A B C Give each process an illusion that it has exclusive access to entire main memory D Process 2 3 2 1 E F G H

But In Reality… Process 1 Process 2 14 D 13 12 E 11 10 C 9 8 7 B G 6 H 5 Process 2 4 A 3 2 F 1 Physical Memory

How do we create the illusion? 14 D 13 12 Process 1 3 2 1 A E 11 B 10 C C 9 D 8 7 B G 6 H 5 Process 2 3 2 1 E 4 F A 3 G 2 H F 1 Physical Memory

How do we create the illusion? 14 D 13 12 Process 1 3 2 1 A E 11 B 10 C All problems in computer science can be solved by another level of indirection. – David Wheeler C 9 D 8 7 B G 6 H 5 Process 2 3 2 1 E 4 F A 3 G 2 H F 1 Physical Memory

How do we create the illusion? 14 D 13 12 Process 1 3 2 1 A E 11 B Map virtual address to physical address 10 C C 9 D 8 Virtual address Physical address 7 B Memory management unit (MMU) takes care of the mapping G 6 H 5 Process 2 3 2 1 E 4 F A 3 G 2 H F 1 Virtual Memory (just a concept; does not exist physically) Physical Memory

How do we create the illusion? 14 Process 1 wants to access data C D 13 12 Process 1 Process 1 thinks it is stored at addr 1 3 2 1 A E 11 B So CPU generates addr 1 10 C C 9 D This addr is intercepted by MMU 8 Virtual address B Physical address 7 G 6 MMU knows this is a virtual addr H 5 Process 2 3 2 1 E MMU looks at the mapping 4 F A 3 G Virtual addr 1 -> Physical addr 9 2 H Data at Physical addr 9 is sent to CPU F 1 Virtual Memory (just a concept; does not exist physically) And that data is indeed C!!! Physical Memory

How do we create the illusion? 14 D 13 12 Process 1 3 2 1 A E 11 B Map virtual address to physical address 10 C C 9 D 8 7 B Memory management unit (MMU) takes care of the mapping G 6 H 5 Process 2 3 2 1 E 4 F 3 G 2 H 1 Virtual Memory A F Physical Memory Disk

Big Picture: (Virtual) Memory From a process’s perspective – Process only sees the virtual memory Contiguous memory Process 1 3 2 1 A B Hidden from Process C C D Physical Memory Virtual Memory

Big Picture: (Virtual) Memory From a process’s perspective – Process only sees the virtual memory Contiguous memory No need to recompile - only mappings need to be updated Process 1 3 2 1 A B Hidden from Process C C D Physical Memory Virtual Memory

Big Picture: (Virtual) Memory From a process’s perspective – Process only sees the virtual memory Contiguous memory No need to recompile - only mappings need to be updated C Process 1 3 2 1 A B Hidden from Process C D Physical Memory Virtual Memory

Big Picture: (Virtual) Memory From a process’s perspective – Process only sees the virtual memory Contiguous memory No need to recompile - only mappings need to be updated When run out of memory, MMU maps data on disk in a transparent manner Process 1 3 2 1 A B Hidden from Process C D Physical Memory Virtual Memory C Disk

Next Goal How does Virtual Memory work? i.e. How do we create the “map” that maps a virtual address generated by the CPU to a physical address used by main memory?

Next Goal (after spring break!) How does Virtual Memory work? i.e. How do we create the “map” that maps a virtual address generated by the CPU to a physical address used by main memory?

Virtual Memory Agenda What is Virtual Memory? How does Virtual memory Work? Address Translation Overhead Paging Performance