CSCI206 - Computer Organization & Programming

Slides:



Advertisements
Similar presentations
16.317: Microprocessor System Design I
Advertisements

Virtual Memory Chapter 18 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S. Dandamudi.
Computer Organization CS224 Fall 2012 Lesson 44. Virtual Memory  Use main memory as a “cache” for secondary (disk) storage l Managed jointly by CPU hardware.
CS 153 Design of Operating Systems Spring 2015
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
CSCE 212 Chapter 7 Memory Hierarchy Instructor: Jason D. Bakos.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory.
©UCB CS 162 Ch 7: Virtual Memory LECTURE 13 Instructor: L.N. Bhuyan
Memory Management April 28, 2000 Instructor: Gary Kimura.
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
CS 241 Section Week #12 (04/22/10).
Virtual Memory By: Dinouje Fahih. Definition of Virtual Memory Virtual memory is a concept that, allows a computer and its operating system, to use a.
CS 346 – Chapter 8 Main memory –Addressing –Swapping –Allocation and fragmentation –Paging –Segmentation Commitment –Please finish chapter 8.
Operating Systems Chapter 8
Some VM Complications Extra memory accesses Page tables are huge
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
IT253: Computer Organization
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Hardware.
4.3 Virtual Memory. Virtual memory  Want to run programs (code+stack+data) larger than available memory.  Overlays programmer divides program into pieces.
Introduction: Memory Management 2 Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive memory.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
Virtual Memory.  Next in memory hierarchy  Motivations:  to remove programming burdens of a small, limited amount of main memory  to allow efficient.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
Lab4: Virtual Memory CS 3410 : Computer System Organization & Programming Spring 2015.
CHAPTER 3-3: PAGE MAPPING MEMORY MANAGEMENT. VIRTUAL MEMORY Key Idea Disassociate addresses referenced in a running process from addresses available in.
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
Constructive Computer Architecture Virtual Memory: From Address Translation to Demand Paging Arvind Computer Science & Artificial Intelligence Lab. Massachusetts.
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”
3/1/2002CSE Virtual Memory Virtual Memory CPU On-chip cache Off-chip cache DRAM memory Disk memory Note: Some of the material in this lecture are.
CS203 – Advanced Computer Architecture Virtual Memory.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
Memory Management & Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.
CS161 – Design and Architecture of Computer
Lecture 11 Virtual Memory
Memory Management Virtual Memory.
Improving Memory Access The Cache and Virtual Memory
Virtual Memory Chapter 7.4.
ECE232: Hardware Organization and Design
Memory COMPUTER ARCHITECTURE
CS161 – Design and Architecture of Computer
Lecture 12 Virtual Memory.
Virtual Memory User memory model so far:
From Address Translation to Demand Paging
Some Real Problem What if a program needs more memory than the machine has? even if individual programs fit in memory, how can we run multiple programs?
Memory Hierarchy Virtual Memory, Address Translation
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
CS 105 “Tour of the Black Holes of Computing!”
Page that info back into your memory!
Virtual Memory Hardware
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
Translation Buffers (TLB’s)
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE451 Virtual Memory Paging Autumn 2002
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Translation Buffers (TLB’s)
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CS 105 “Tour of the Black Holes of Computing!”
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CS 105 “Tour of the Black Holes of Computing!”
Translation Buffers (TLBs)
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Review What are the advantages/disadvantages of pages versus segments?
4.3 Virtual Memory.
Memory Management & Virtual Memory
Virtual Memory 1 1.
Presentation transcript:

CSCI206 - Computer Organization & Programming Introduction to Virtual Memory zyBook: 12.9

Review Memory Map Heap has largest address Code begins near the bottom 0x7FFF FFFF is the last byte in 32-bit MIPS Code begins near the bottom 0x0040 0000 in MIPS 2 GB memory range

Problem We commonly run multiple programs on our computers (show top). We don’t share data between programs! How do separate programs access the same memory map without conflict?

Virtual Memory A simulated address space is provided for each process by the operating system. These addresses are called virtual addresses. The operating system maintains a mapping between PID+virtual address to physical address.

Virtual Memory (aka logical memory)

VM - Basics Each program is given the illusion of owning a large / flat memory space Virtual memory supports a larger address space than is physically available because of spatial / temporal locality we can (usually) move some data to disk (swap) Transparent to the programmer Efficient... with a bit extra little hardware

How VM Works Like cache, VM is allocated in chunks called pages The Page offset is consistent between virtual and physical Common page size is 4KB Translations stored by the OS in the Page Table In the example on the left, we have 4G VM, 1 G physical memory

Address range of VM The range of address for VM is somewhat independent of amount of the physical memory VM addresses for a process (program) are contiguous Physical memory addresses do not have to be contiguous

What is a page fault? There are more virtual addresses than physical addresses. As a result, contents of some virtual addresses are located on disk If a virtual address is needed by a program and it is currently on disk a page fault occurs The OS allocates physical RAM and move data from disk to RAM (and possibly moves other data from RAM to disk)

Page Table (OS) The OS stores the virtual to physical mapping in a table in memory. indexed by virtual page number. the contents are the physical page numbers.

Page Table Question How many pages can there be in a 32-bit system with 4 KB pages?

Page Table Question How many pages can there be in a 32-bit system with 4 KB pages? 4 KB nees 12 bits as offset Which leaves 20 bits to count pages, which is 2^20 ~= 1 million pages

Page Table Question How big is the page table for a 32-bit system with 4 KB pages?

Page Table Question How big is the page table for a 32-bit system with 4 KB pages? There are 2^20 entries, each with 19 bits (18 addr bits, 1 valid bit), a total of 2.375 MB

Hardware Issues Program memory accesses use virtual addresses. Hardware uses physical addresses to access data (RAM). How does hardware (CPU) handle a memory access?

Cache with Virtual Addresses? RAM V to P ? Offset CACHE Index Tag V to P ? Does the cache use virtual addresses or physical addresses?

Virtual Memory Caching All programs have their own virtual address space Therefore, two programs will refer to the same addresses, but expect to find their own data! As a result, we cannot cache using virtual addresses There is no way to tell data from each process apart using only the virtual address However, the virtual to physical translation is on the critical path for every cache access! This needs to be fast, so we create a special cache, called the translation lookaside buffer (TLB), just for caching the page table!

TLB Memory access begins with a TLB access to find the physical address, then access the cache. The TLB is flushed on context switches, but cache contents are not!