Lecture 11 Virtual Memory

Slides:



Advertisements
Similar presentations
Virtual Memory Basics.
Advertisements

Chapter 4 Memory Management Basic memory management Swapping
Datorteknik VirtualMemory bild 1 Virtual Memory User memory model so far: Separate Instruction and Data memory In reality they share the same memory space.
1 Memory hierarchy and paging Electronic Computers M.
Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.
16.317: Microprocessor System Design I
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.
Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
Virtual Memory Adapted from lecture notes of Dr. Patterson and Dr. Kubiatowicz of UC Berkeley.
CSCE 212 Chapter 7 Memory Hierarchy Instructor: Jason D. Bakos.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Virtual Memory Adapted from lecture notes of Dr. Patterson and Dr. Kubiatowicz of UC Berkeley and Rabi Mahapatra & Hank Walker.
1 Lecture 14: Virtual Memory Topics: virtual memory (Section 5.4) Reminders: midterm begins at 9am, ends at 10:40am.
S.1 Review: The Memory Hierarchy Increasing distance from the processor in access time L1$ L2$ Main Memory Secondary Memory Processor (Relative) size of.
Translation Buffers (TLB’s)
Virtual Memory. Why do we need VM? Program address space: 0 – 2^32 bytes –4GB of space Physical memory available –256MB or so Multiprogramming systems.
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
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.
Some VM Complications Extra memory accesses Page tables are huge
Lecture 19: Virtual Memory
IT253: Computer Organization
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
Virtual Memory Expanding Memory Multiple Concurrent Processes.
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)
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
1 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?
Virtual Memory Additional Slides Slide Source: Topics Address translation Accelerating translation with TLBs class12.ppt.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Demand Paging.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
1  2004 Morgan Kaufmann Publishers Chapter Seven Memory Hierarchy-3 by Patterson.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
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)
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”
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.
Virtual Memory Chapter 8.
CS161 – Design and Architecture of Computer
Virtual Memory So, how is this possible?
Virtual Memory Chapter 7.4.
Memory COMPUTER ARCHITECTURE
CS161 – Design and Architecture of Computer
Lecture 12 Virtual Memory.
Section 9: Virtual Memory (VM)
Virtual Memory User memory model so far:
CS703 - Advanced Operating Systems
Section 9: Virtual Memory (VM)
From Address Translation to Demand Paging
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.
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?
CSE 153 Design of Operating Systems Winter 2018
CSCI206 - Computer Organization & Programming
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Lecture 23: Cache, Memory, Virtual Memory
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Translation Buffers (TLB’s)
Virtual Memory Overcoming main memory size limitation
Contents Memory types & memory hierarchy Virtual memory (VM)
CSE451 Virtual Memory Paging Autumn 2002
Virtual Memory Prof. Eric Rotenberg
Translation Buffers (TLB’s)
CSC3050 – Computer Architecture
Paging and Segmentation
CSE 153 Design of Operating Systems Winter 2019
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.
Virtual Memory 1 1.
Presentation transcript:

Lecture 11 Virtual Memory User memory model so far: Separate Instruction and Data memory In reality they share the same memory space 0x00000000 … User space Instruction memory Data memory 0x7fffffff

Virtual to Physical Address Mapping 0x00000000 … 0x7fffffff User space Instruction and Data 2 GB Virtual address Physical address Physical memory Virtual memory 2 Gb, HUGE amount Physical memory only 16 Mb

Address Mapping CP0 MIPS PIPELINE Instr Data 32 32 Physical memory 16 Mb 24-bit Physical Address 32-bit Virtual Address

Virtual Address User 1 2 Gb Virtual Address 32-bit 31 10 9 Page 0 Page 0 Page 1 Selects Page # x Offset within page #x …. Page x 1024 Bytes Page x Page n 22 10 2 Pages 2 Addresses

Virtual Memory Virtual Address 2 Gb Primary Memory Physical memory 16 Mb Page 0 Page 1 Page x …. Page 1 Page x Secondary Storage Hard Disk 2 Gb Page n Page 0 Not Allocated Yet

Memory Resident Pages Only very few pages are RESIDENT in physical 31 10 9 Virtual 32-bit Address Selects Page # x Offset Address Translation of page #x 23 10 9 Physical 24-bit Address

Page Fault What about a NON RESIDENT page? We know the Virtual Address, but: No Physical Address, since the page is on Hard Disk (SWAPPED) What about a not allocated page We try to access a Virtual Address that we have not (yet) access to, that is an ERROR In both cases we get a PAGE FAULT

Page Table Virtual Address 2 Gb Page Resident Physical Memory Page x Physical Addr [23:10] Page x Y …. Hard Disk Page y N Place on Hard Disk Page y For Non Resident Pages we get a PAGE FAULT

Swapping Virtual Address Physical Memory 2 Gb Resident …. Page y Secondary Storage Physical Addr [23:10] Page y Y Place on Hard Disk Page y The OS copies Page y to physical memory and restarts the failing user instruction

Page Fault and the OS A Page Fault is handled by the Kernel (OS) 1) If physical memory not full Copy the page from hard disk to a empty page X in physical memory Update the Page Table, Resident = YES, Physical Addr [23:10]=X Restart the failing instruction in the user program 2) If physical memory full Choose one page X from physical memory, store it on hard disk at XX Update the Page Table (X), Resident = NO, place on HD = XX Proceed with 1) What if page X is unchanged (only read operations), skip storing to hard disk, just set Resident = NO

Multiple User Processes Virtual memory n * 2 Gb Virtual address Physical address 16 Mbyte 0x00000000 … 0x7fffffff User 1 Page Table 1 User n 0x00000000 … 0x7fffffff User 2 Page Table 2 User 1 HD address …. 0x00000000 … 0x7fffffff User n Page Table n User n User 1 User 2 User 1 User 2

Where do we store the Page Tables? We store the Page Tables in Kernel memory Protected from User access! 16 Mbyte User Memory Dirty Resident 22 Physical Addr [23:10] 2 entries huge array! Store only allocated pages D R Place on Hard Disk Kernel Memory Page Table 1 Page Table 2 Page Table n

Address Mapping CP0 User Memory MIPS PIPELINE Instr Data 32 32 24-bit Physical Address 32-bit Virtual Address User process 2 running Kernel Memory Page Table 1 Here we need page table 2 for address mapping Page Table 2 Page Table n

Translation Lookaside Buffer (TLB) CP0 On TLB hit, the 32-bit virtual address is translated into a 24-bit physical address by hardware We never call the Kernel! User Memory MIPS PIPELINE 32 32 24 D R Physical Addr [23:10] Virtual Address Kernel Memory Page Table 1 Page Table 2 Page Table n

Memory Hierarchy Hardware is FAST but EXPENSIVE 14 Hardware is FAST but EXPENSIVE No need to use more than 2 entries STILL TO BIG! Make is smaller. Select a subset of the Page Table and store it in the TLB 16 Mb = 2 pages 14 User Memory Valid bit 24 V 22-bit Page # D Physical Addr [23:10] Kernel Memory Page Table 2

Address Translation A TLB hit, we get a physical address The Page # found in TLB and Valid entry (V-bit) If a Write operation, set Dirty (D-bit) A TLB miss, causes a TLB miss exception Check if Page Resident in Physical memory, if not Page Fault and the OS slide if page X is swapped to hard disk and X in TLB, clear V bit Find a free TLB entry and update it 1) 22-bit Page #, set V-bit, clear D-bit, 14-bit physical address If full, chose a TLB entry if D-bit, update Page Table Dirty bit, proceed with 1)

TLB control CP0 Control Signals TLB MISS R/W Page Table MIPS PIPELINE 32 Data bus Virtual Addr