Understanding the Design of Virtual Memory. Zhiqiang Lin

Size: px
Start display at page:

Download "Understanding the Design of Virtual Memory. Zhiqiang Lin"

Transcription

1 CS 6V8-05: System Security and Malicious Code Analysis Understanding the Design of Virtual Memory Zhiqiang Lin Department of Computer Science University of Texas at Dallas February 27 th, 202

2 Outline Basic Concepts 2 Why Virtual Memory Caching Memory management Memory protection 3 Address translation 4 Summary

3 Where we are today Splitting the Ker nel The System Call Interface Process management Memory management Filesystems Device control Networking Kernel subsystems Concurrency, multitasking Virtual memory Files and dirs: the VFS Ttys & device access Connectivity Features implemented Archdependent Code Memory manager File system types Block devices Character devices Network subsystem IF drivers Software support Hardware CPU Memory Disks & CDs Consoles, etc. Network interfaces features implemented as modules Figur e -. A split view of the kernel This diagram is from Linux Device Driver book (page 5) throughout the whole system. In addition, Linux supports multiple filesystem

4 Outline Basic Concepts 2 Why Virtual Memory Caching Memory management Memory protection 3 Address translation 4 Summary

5 Von Neumann Architecture Data Software code is loaded memory Program data is also in the memory

6 A System Using Physical Addressing A System Using Physical Addressing Carnegie Mell CPU Physical address (PA) 4 Main memory 0: : 2: 3: 4: 5: 6: 7: 8:... M-: Data word Used Used in simple in simple systems systems like like embedded embedded microcontrollers microcontrollers in in devices devices like like cars, cars, elevators, elevators, and and digital digital picture picture frames frames

7 Carnegie Mellon A System Using Virtual Addressing A System Using Virtual Addressing CPU Chip CPU Virtual address (VA) 400 MMU Physical address (PA) 4 Main memory 0: : 2: 3: 4: 5: 6: 7: 8:... M-: Data word Used in all modern servers, desktops, and laptops Used One of inthe all great modern ideas servers, in computer desktops, science and laptops One of the greatest ideas in computer science 4

8 Virtual Memory In computing, virtual memory is a memory management technique developed for multitasking kernels. This technique virtualizes a computer architecture s various forms of computer data storage (such as random-access memory and disk storage), allowing a program to be designed as though there is only one kind of memory, "virtual" memory, which behaves like directly addressable read/write memory (RAM).

9 Who invented this Peter J. Denning, The Working Set Model for Program Behavior, Proceedings of the First ACM Symposium on Operating Systems Principles, October 967, Gatlinburg, TN, USA. This paper introduced the working set model, which has became a key concept in understanding of locality of memory references and for implementing virtual memory. Most paging algorithms can trace their roots back to this work. This paper introduced the working set model, which has became a key concept in understanding of locality of memory references and for implementing virtual memory. Most paging algorithms can trace their roots back to this work. Andre Bensoussan, Charlie T. Clingen, Robert C. Daley, The Multics Virtual Memory: Concepts and Design, Communications of the ACM 5(5):308-38, May 972.

10 Who invented this Dennis M. Ritchie and Ken Thompson, The UNIX Time-Sharing System, Proceedings of the Fourth ACM Symposium on Operating Systems Principles, October 973, Yorktown Heights, NY, USA. Edsger W. Dijkstra, The Structure of the THE Multiprogramming System, Proceedings of the First ACM Symposium on Operating Systems Principles, October 967, Gatlinburg, TN, USA. The first paper to suggest that an operating system be built in a structured way. That structure was a series of layers, each a virtual machine that introduced abstractions built using the functionality of lower layer. The paper stimulated a great deal of subsequent work in building operating systems as structured systems.

11 Virtual Memory of a Linux Process Virtual Memory of a Linux Process Carnegie Mellon Different for each process Identical for each process %esp Process-specific data structs (ptables, task and mm structs, kernel stack) Physical memory Kernel code and data User stack Kernel virtual memory brk 0x (32) 0x (64) 0 Memory mapped region for shared libraries Runtime heap (malloc) Uninitialized data (.bss) Initialized data (.data) Program text (.text) Process virtual memory 37

12 How hardware support (MMU) 0-bits 0-bits 2-bits Offset in PGD Offset in PDE Offset in Data Page Page Directory PDE Page Table PTE pte Data Page CR3 2-bits.. X 0 0 X X X 0 0 X cache write present reserved page size cache through writable Page Directory Entry (PDE) disabled accessed 2-bits.. Page Table Entry (PTE) 0 global page U/S R/W present

13 Basic Concepts space. To understand Why this Virtual in more Memory details, let us first take a look Address at how translation the paging in x86 works. Summary 2. Paging in x86 Processor A more concrete view The x86 processor divides the physical address space (or physical memory) in 4 KB pages. Thus to address 4GB of memory, we will need Mega (024x024) 4KB pages. The processor uses a two level structure to refer to these Mega pages. You can think of it as a two dimensional matrix of 024x024 elements. The first dimension is known as Page Directory and second dimension is known as Page Table. Thus we can create Page directory with 024 entries, each of which points to a Page Table. This will allow us to have 024 page tables. Each page table in turn can have 024 entries, each of which points to a 4 KB page. Graphically it looks something like: Page Directory Index = 0, Address = X Index =, Address = Y Index = 023, Address = Z Page Tables Index = 0, Address = X Index =, Address = X2 Index = 2, Address = X3 Index = 023, Address = Xn Index = 0, Address = Y Index =, Address = Y2 Index = 2, Address = Y3 Index = 023, Address = Yn Index = 0, Address = Z Index =, Address = Z2 Index = 2, Address = Z3 Index = 023, Address = Zn Physical Address Address X 4 KB Page Address Yn 4 KB Page Address X3 4 KB Page Unused Address Xn 4 KB Page Unused Address Y 4KB Page Address X2 4KB Page Address Z2 4KB Page Address Y2 4KB Page Address Z3 4KB Page Unused Unused Address Zn 4KB Page Address Y3 4KB Page Address Z 4KB Page Unused Unused so on Page of 5

14 Other Relevant Concepts Memory address Address space Virtual address space Page (computing) Page table Paging Working set Memory management unit Cache algorithms Page replacement algorithm Segmentation (memory) Memory management Memory allocation Protected mode, an x86 mode that allows for virtual memory....

15 Outline Basic Concepts 2 Why Virtual Memory Caching Memory management Memory protection 3 Address translation 4 Summary

16 Address Spaces Linear address space: Ordered set of contiguous non-negative integer addresses: {0,, 2, 3... } Virtual address space: Set of N = 2 n virtual addresses: {0,, 2, 3,..., N-} Physical address space: Set of M = 2 m physical addresses: {0,, 2, 3,..., M-} Clean distinction between data (bytes) and their attributes (addresses) Each object can now have multiple addresses Every byte in main memory: one physical address, one (or more) virtual addresses

17 Why Virtual Memory (VM)? Uses main memory efficiently Use DRAM as a cache for the parts of a virtual address space Simplifies memory management Each process gets the same uniform linear address space Isolates address spaces One process can t interfere with another s memory User program cannot access privileged kernel information

18 Outline Basic Concepts 2 Why Virtual Memory Caching Memory management Memory protection 3 Address translation 4 Summary

19 VM as a Tool for Caching VM as a Tool for Caching Virtual memory is an array of N contiguous bytes stored Virtual memory is an array of contiguous bytes stored on on disk. disk. The The contents of of the array on disk are cached in in physical memory (DRAM cache) These These cache cache blocks blocks are called are called pages pages (size is (size P = 2 is p bytes) P = 2 p bytes) VP 0 VP VP 2 n-p - Virtual memory 0 Unallocated Cached Uncached Unallocated Cached Uncached Cached Uncached N- Virtual pages (VPs) stored on disk Physical memory 0 M- Empty Empty Empty PP 0 PP PP 2 m-p - Physical pages (PPs) cached in DRAM

20 DRAM Cache Organization DRAM cache organization driven by the enormous miss penalty DRAM is about 0x slower than SRAM Disk is about 0,000x slower than DRAM Consequences Large page (block) size: typically 4-8 KB, sometimes 4 MB Fully associative Any VP can be placed in any PP Requires a large mapping function - different from CPU caches Highly sophisticated, expensive replacement algorithms Too complicated and open-ended to be implemented in hardware Write-back rather than write-through

21 Page Tables Page Tables Carnegie Mellon A page table is an array of page table entries (PTEs) that maps virtual pages to physical pages. A page table is an array of page table entries (PTEs) that Per-process kernel data structure in DRAM maps virtual pages to physical pages. Per-process kernel data structure in DRAM Physical page number or Valid disk address PTE 0 0 null 0 0 null 0 PTE 7 Memory resident page table (DRAM) Physical memory (DRAM) VP VP 2 VP 7 VP 4 Virtual memory (disk) VP VP 2 VP 3 VP 4 VP 6 VP 7 PP 0 PP 3 0

22 Page Hit Page Hit Carnegie Mellon Page hit: reference to VM word that is in physical memory (DRAM Page cache hit: reference hit) to VM word that is in physical memory (DRAM cache hit) Virtual address Physical page number or Valid disk address PTE 0 0 null 0 0 null 0 PTE 7 Memory resident page table (DRAM) Physical memory (DRAM) VP VP 2 VP 7 VP 4 Virtual memory (disk) VP VP 2 VP 3 VP 4 VP 6 VP 7 PP 0 PP 3

23 Page Fault Page Fault Carnegie Mellon Page fault: reference to VM word that is not in physical memory Page fault: (DRAM reference cache to miss) VM word that is not in physical memory (DRAM cache miss) Virtual address Physical page number or Valid disk address PTE 0 0 null 0 0 null 0 PTE 7 Memory resident page table (DRAM) Physical memory (DRAM) VP VP 2 VP 7 VP 4 Virtual memory (disk) VP VP 2 VP 3 VP 4 VP 6 VP 7 PP 0 PP 3 2

24 Handling Page Fault Handling Page Fault Page miss causes page fault (an exception) Page miss causes page fault (an exception) Carnegie Mellon Virtual address Physical page number or Valid disk address PTE 0 0 null 0 0 null 0 PTE 7 Memory resident page table (DRAM) Physical memory (DRAM) VP VP 2 VP 7 VP 4 Virtual memory (disk) VP VP 2 VP 3 VP 4 VP 6 VP 7 PP 0 PP 3 3

25 Handling Page Fault Handling Page Fault Page miss causes page fault (an exception) Carnegie Mellon Page fault handler selects a victim to be evicted (here VP 4) Page miss causes page fault (an exception) Page fault handler selects a victim to be evicted (here VP 4) Virtual address Physical page number or Valid disk address PTE 0 0 null 0 0 null 0 PTE 7 Memory resident page table (DRAM) Physical memory (DRAM) VP VP 2 VP 7 VP 4 Virtual memory (disk) VP VP 2 VP 3 VP 4 VP 6 VP 7 PP 0 PP 3 4

26 5 Handling Page Fault Page miss causes page fault (an exception) Handling Page Fault Page fault handler selects a victim to be evicted (here VP 4) Page miss causes page fault (an exception) Offending instruction is restarted: page hit! Page fault handler selects a victim to be evicted (here VP 4) Carnegie Mellon Virtual address Physical page number or Valid disk address PTE 0 0 null 0 0 null 0 PTE 7 Memory resident page table (DRAM) Physical memory (DRAM) VP VP 2 VP 7 VP 3 Virtual memory (disk) VP VP 2 VP 3 VP 4 VP 6 VP 7 PP 0 PP 3

27 Locality Virtual memory works because of locality At any point in time, programs tend to access a set of active virtual pages called the working set Programs with better temporal locality will have smaller working sets If (working set size < main memory size) Good performance for one process after compulsory misses If ( SUM(working set sizes) > main memory size ) Thrashing: Performance meltdown where pages are swapped (copied) in and out continuously

28 Outline Basic Concepts 2 Why Virtual Memory Caching Memory management Memory protection 3 Address translation 4 Summary

29 Basic Concepts Why Virtual Memory Address translation Carnegie Summary Mellon VM as a Tool for Memory Management VM as a Tool for Memory Management Key Key idea: idea: each each process process has has its own its own virtual virtual address address space space It can view memory as a simple linear array It can view memory as a simple linear array Mapping function scatters addresses through physical Mapping memory function scatters addresses through physical memory Well chosen Well chosen mappings mappings simplify simplify memory memory allocation allocation and management and management Virtual Address Space for Process : 0 VP VP 2... Address translation 0 PP 2 Physical Address Space (DRAM) Virtual Address Space for Process 2: N- 0 VP VP 2... PP 6 PP 8... (e.g., read-only library code) N- M- 9

30 Basic Concepts Why Virtual Memory Address translation Carnegie Summary Mellon VM as a Tool for Memory Management VM as a Tool for Memory Management Memory allocation Key idea: Each each virtual process page has can its be own mapped virtual to any address physical space page It can Aview virtual memory pageas can a simple be stored linear inarray different physical pages at Mapping different function times scatters addresses through physical memory Sharing Well chosen codemappings and datasimplify amongmemory processes allocation and management Map virtual pages to the same physical page (here: PP 6) Virtual Address Space for Process : 0 VP VP 2... Address translation 0 PP 2 Physical Address Space (DRAM) Virtual Address Space for Process 2: N- 0 VP VP 2... PP 6 PP 8... (e.g., read-only library code) N- M- 9

31 Simplifying Linking and Loading Linking Each program has similar virtual address space Code, stack, and shared libraries always start at the same address 0xc x Kernel virtual memory User stack (created at runtime) Memory-mapped region for shared libraries Memory invisible to user code %esp (stack pointer) Run-time heap (created by malloc) brk 0x Read/write segment (.data,.bss) Read-only segment (.init,.text,.rodata) Unused Loaded from the executable file

32 Simplifying Linking and Loading Linking Each program has similar virtual address space Code, stack, and shared libraries always start at the same address Loading execve() allocates virtual pages for.text and.data sections = creates PTEs marked as invalid The.text and.data sections are copied, page by page, on demand by the virtual memory system 0xc x x Kernel virtual memory User stack (created at runtime) Memory-mapped region for shared libraries Run-time heap (created by malloc) Read/write segment (.data,.bss) Read-only segment (.init,.text,.rodata) Unused Memory invisible to user code %esp (stack pointer) brk Loaded from the executable file

33 Outline Basic Concepts 2 Why Virtual Memory Caching Memory management Memory protection 3 Address translation 4 Summary

34 VM as a Tool for Memory Protection VM as a Tool for Memory Protection Extend PTEs with permission bits Page Extend fault PTEs handler with permission checks these bits before remapping Page Iffault violated, handler sendchecks processthese SIGSEGV before (segmentation remapping fault) If violated, send process SIGSEGV (segmentation fault) Carnegie Mellon Process i: VP 0: VP : VP 2: SUP No No Yes READ WRITE Yes Yes Yes No Yes Yes Address PP 6 PP 4 PP 2 Physical Address Space PP 2 PP 4 PP 6 Process j: VP 0: VP : VP 2: SUP No Yes No READ WRITE Yes Yes Yes No Yes Yes Address PP 9 PP 6 PP PP 8 PP 9 PP

35 Outline Basic Concepts 2 Why Virtual Memory Caching Memory management Memory protection 3 Address translation 4 Summary

36 VM Address Translation Virtual Address Space V = {0,,..., N-} Physical Address Space P = {0,,..., M-} Address Translation MAP: V P {Ø} For virtual address a: MAP(a) = a if data at virtual address a is at physical address a in P MAP(a) = Ø if data at virtual address a is not in physical memory Either invalid or stored on disk

37 Address Translation With a Page Table Address Translation With a Page Table Page table base register (PTBR) Virtual address n- Virtual page number (VPN) p p- Virtual page offset (VPO) Carnegie Mellon 0 Page table address for process Page table Valid Physical page number (PPN) Valid bit = 0: page not in memory (page fault) m- p Physical page number (PPN) Physical address p- Physical page offset (PPO) 0

38 Address Translation: Page Hit Address Translation: Page Hit Carnegie Mellon CPU Chip CPU VA MMU 2 PTEA PTE 3 PA 4 Cache/ Memory Data 5 ) Processor sends virtual address to MMU ) Processor sends virtual address to MMU 2-3) MMU fetches PTE from page table in memory 4) MMU sends physical address to cache/memory 5) Cache/memory sends data word to processor

39 Address Translation: Page Hit Address Translation: Page Hit Carnegie Mellon CPU Chip CPU VA MMU 2 PTEA PTE 3 PA 4 Cache/ Memory Data 5 ) Processor sends virtual address to MMU ) Processor sends virtual address to MMU 2-3) MMU fetches PTE from page table in memory 2-3) MMU fetches PTE from page table in memory 4) MMU sends physical address to cache/memory 5) Cache/memory sends data word to processor

40 Address Translation: Page Hit Address Translation: Page Hit Carnegie Mellon CPU Chip CPU VA MMU 2 PTEA PTE 3 PA 4 Cache/ Memory Data 5 ) Processor sends virtual address to MMU ) Processor sends virtual address to MMU 2-3) MMU fetches PTE from page table in memory 2-3) MMU fetches PTE from page table in memory 4) MMU sends physical address to cache/memory 4) MMU sends physical address to cache/memory 5) Cache/memory sends data word to processor

41 Address Translation: Page Hit Address Translation: Page Hit Carnegie Mellon CPU Chip CPU VA MMU 2 PTEA PTE 3 PA 4 Cache/ Memory Data 5 ) Processor sends virtual address to MMU ) Processor sends virtual address to MMU 2-3) MMU fetches PTE from page table in memory 2-3) MMU fetches PTE from page table in memory 4) MMU sends physical address to cache/memory 4) MMU sends physical address to cache/memory 5) Cache/memory 5) Cache/memory sends sends data data word word to processor to processor

42 Address Translation: Page Fault Address Translation: Page Fault Exception Page fault handler 4 Carnegie Mellon CPU Chip CPU VA 7 MMU 2 PTEA PTE 3 Cache/ Memory Victim page 5 New page Disk 6 ) Processor sends virtual address to MMU 2-3) ) MMU Processor fetches sends PTE from virtual page address table in memory to MMU 4) Valid bit is zero, so MMU triggers page fault exception 5) Handler identifies victim (and, if dirty, pages it out to disk) 6) Handler pages in new page and updates PTE in memory 7) Handler returns to original process, restarting faulting instruction 29

43 Address Translation: Page Fault Address Translation: Page Fault Exception Page fault handler 4 Carnegie Mellon CPU Chip CPU VA 7 MMU 2 PTEA PTE 3 Cache/ Memory Victim page 5 New page Disk 6 ) Processor sends virtual address to MMU 2-3) ) MMU Processor fetches sends PTE from virtual page address table in memory to MMU 4) 2-3) Valid MMU bit is zero, fetches so MMU PTEtriggers from page fault tableexception in memory 5) Handler identifies victim (and, if dirty, pages it out to disk) 6) Handler pages in new page and updates PTE in memory 7) Handler returns to original process, restarting faulting instruction 29

44 Address Translation: Page Fault Address Translation: Page Fault Exception Page fault handler 4 Carnegie Mellon CPU Chip CPU VA 7 MMU 2 PTEA PTE 3 Cache/ Memory Victim page 5 New page Disk 6 ) Processor sends virtual address to MMU 2-3) ) MMU Processor fetches sends PTE from virtual page address table in memory to MMU 4) 2-3) Valid MMU bit is zero, fetches so MMU PTEtriggers from page fault tableexception in memory 5) 4) Handler Valid identifies bit is zero, victim so MMU (and, if triggers dirty, pages page it out fault to disk) exception 6) Handler pages in new page and updates PTE in memory 7) Handler returns to original process, restarting faulting instruction 29

45 Address Translation: Page Fault Address Translation: Page Fault Exception Page fault handler 4 Carnegie Mellon CPU Chip CPU VA 7 MMU 2 PTEA PTE 3 Cache/ Memory Victim page 5 New page Disk 6 ) Processor sends virtual address to MMU 2-3) ) MMU Processor fetches sends PTE from virtual page address table in memory to MMU 4) 2-3) Valid MMU bit is zero, fetches so MMU PTEtriggers from page fault tableexception in memory 5) 4) Handler Valid identifies bit is zero, victim so MMU (and, if triggers dirty, pages page it out fault to disk) exception 6) Handler pages in new page and updates PTE in memory 5) Handler identifies victim (and, if dirty, pages it out to disk) 7) Handler returns to original process, restarting faulting instruction 29

46 Address Translation: Page Fault Address Translation: Page Fault Exception Page fault handler 4 Carnegie Mellon CPU Chip CPU VA 7 MMU 2 PTEA PTE 3 Cache/ Memory Victim page 5 New page Disk 6 ) Processor sends virtual address to MMU 2-3) ) MMU Processor fetches sends PTE from virtual page address table in memory to MMU 4) 2-3) Valid MMU bit is zero, fetches so MMU PTEtriggers from page fault tableexception in memory 5) 4) Handler Valid identifies bit is zero, victim so MMU (and, if triggers dirty, pages page it out fault to disk) exception 6) Handler pages in new page and updates PTE in memory 5) Handler identifies victim (and, if dirty, pages it out to disk) 7) Handler returns to original process, restarting faulting instruction 6) Handler pages in new page and updates PTE in memory 29

47 Address Translation: Page Fault Address Translation: Page Fault Exception Page fault handler 4 Carnegie Mellon CPU Chip CPU VA 7 MMU 2 PTEA PTE 3 Cache/ Memory Victim page 5 New page Disk 6 ) Processor sends virtual address to MMU 2-3) ) MMU Processor fetches sends PTE from virtual page address table in memory to MMU 4) 2-3) Valid MMU bit is zero, fetches so MMU PTEtriggers from page fault tableexception in memory 5) 4) Handler Valid identifies bit is zero, victim so MMU (and, if triggers dirty, pages page it out fault to disk) exception 6) Handler pages in new page and updates PTE in memory 5) Handler identifies victim (and, if dirty, pages it out to disk) 7) Handler returns to original process, restarting faulting instruction 6) Handler pages in new page and updates PTE in memory 7) Handler returns to original process, restarting faulting instruction 29

48 Carnegie Me Integrating VM and Cache Integrating VM and Cache PTE CPU Chip CPU VA MMU PTEA PA PTEA hit PTEA miss PA miss PTE PTEA PA Memory PA hit Data Data L cache VA: virtual address, PA: physical address, PTE: page table entry, PTEA = PTE address

49 Speeding up Translation with a TLB Page table entries (PTEs) are cached in L like any other memory word PTEs may be evicted by other data references PTE hit still requires a small L delay Solution: Translation Lookaside Buffer (TLB) Maps virtual page numbers to physical page numbers Contains complete page table entries for a number of pages

50 Carnegie M TLB Hit TLB Hit CPU Chip TLB 2 PTE VPN 3 CPU VA MMU PA 4 Cache/ Memory Data 5 A TLB hit eliminates a memory access

51 Basic Concepts Why Virtual Memory Address translation Carnegie Summary Mellon TLB Miss TLB Miss CPU Chip TLB 4 2 PTE VPN 3 CPU VA MMU PTEA PA Cache/ Memory 5 Data 6 A TLB miss incurs an additional memory access (the PTE) Fortunately, TLB misses are rare. Why? 33

52 Outline Basic Concepts 2 Why Virtual Memory Caching Memory management Memory protection 3 Address translation 4 Summary

53 Summary Programmer s view of virtual memory Each process has its own private linear address space Cannot be corrupted by other processes System view of virtual memory Uses memory efficiently by caching virtual memory pages Efficient because of locality Simplifies memory management and programming Simplifies protection by providing a convenient interpositioning point to check permissions

54 References Dening BEFORE MEMORY WAS VIRTUAL Linux device drivers, Addison-wisely. Understanding Linux virtual memory manager Understanding Linux kernel (3rd edition) f0/www/lectures/5-vm-concepts.pdf

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition Carnegie Mellon Virtual Memory: Concepts 5-23: Introduction to Computer Systems 7 th Lecture, October 24, 27 Instructor: Randy Bryant 2 Hmmm, How Does This Work?! Process Process 2 Process n Solution:

More information

Computer Systems. Virtual Memory. Han, Hwansoo

Computer Systems. Virtual Memory. Han, Hwansoo Computer Systems Virtual Memory Han, Hwansoo A System Using Physical Addressing CPU Physical address (PA) 4 Main memory : : 2: 3: 4: 5: 6: 7: 8:... M-: Data word Used in simple systems like embedded microcontrollers

More information

Processes and Virtual Memory Concepts

Processes and Virtual Memory Concepts Processes and Virtual Memory Concepts Brad Karp UCL Computer Science CS 37 8 th February 28 (lecture notes derived from material from Phil Gibbons, Dave O Hallaron, and Randy Bryant) Today Processes Virtual

More information

CSE 153 Design of Operating Systems

CSE 153 Design of Operating Systems CSE 53 Design of Operating Systems Winter 28 Lecture 6: Paging/Virtual Memory () Some slides modified from originals by Dave O hallaron Today Address spaces VM as a tool for caching VM as a tool for memory

More information

Virtual Memory: Concepts

Virtual Memory: Concepts Virtual Memory: Concepts 5-23: Introduction to Computer Systems 7 th Lecture, March 2, 27 Instructors: Franz Franchetti & Seth Copen Goldstein Hmmm, How Does This Work?! Process Process 2 Process n Solution:

More information

Carnegie Mellon. 16 th Lecture, Mar. 20, Instructors: Todd C. Mowry & Anthony Rowe

Carnegie Mellon. 16 th Lecture, Mar. 20, Instructors: Todd C. Mowry & Anthony Rowe Virtual Memory: Concepts 5 23 / 8 23: Introduction to Computer Systems 6 th Lecture, Mar. 2, 22 Instructors: Todd C. Mowry & Anthony Rowe Today Address spaces VM as a tool lfor caching VM as a tool for

More information

14 May 2012 Virtual Memory. Definition: A process is an instance of a running program

14 May 2012 Virtual Memory. Definition: A process is an instance of a running program Virtual Memory (VM) Overview and motivation VM as tool for caching VM as tool for memory management VM as tool for memory protection Address translation 4 May 22 Virtual Memory Processes Definition: A

More information

Virtual Memory: Concepts

Virtual Memory: Concepts Virtual Memory: Concepts Instructor: Dr. Hyunyoung Lee Based on slides provided by Randy Bryant and Dave O Hallaron Today Address spaces VM as a tool for caching VM as a tool for memory management VM as

More information

Virtual Memory. CS61, Lecture 15. Prof. Stephen Chong October 20, 2011

Virtual Memory. CS61, Lecture 15. Prof. Stephen Chong October 20, 2011 Virtual Memory CS6, Lecture 5 Prof. Stephen Chong October 2, 2 Announcements Midterm review session: Monday Oct 24 5:3pm to 7pm, 6 Oxford St. room 33 Large and small group interaction 2 Wall of Flame Rob

More information

This lecture. Virtual Memory. Virtual memory (VM) CS Instructor: Sanjeev Se(a

This lecture. Virtual Memory. Virtual memory (VM) CS Instructor: Sanjeev Se(a Virtual Memory Instructor: Sanjeev Se(a This lecture (VM) Overview and mo(va(on VM as tool for caching VM as tool for memory management VM as tool for memory protec(on Address transla(on 2 Virtual Memory

More information

Lecture 19: Virtual Memory: Concepts

Lecture 19: Virtual Memory: Concepts CSCI-UA.2-3 Computer Systems Organization Lecture 9: Virtual Memory: Concepts Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted (and slightly modified) from: Clark Barrett

More information

Virtual Memory: Concepts

Virtual Memory: Concepts Virtual Memory: Concepts 5-23 / 8-23: Introduc=on to Computer Systems 6 th Lecture, Mar. 8, 24 Instructors: Anthony Rowe, Seth Goldstein, and Gregory Kesden Today VM Movaon and Address spaces ) VM as a

More information

Systems Programming and Computer Architecture ( ) Timothy Roscoe

Systems Programming and Computer Architecture ( ) Timothy Roscoe Systems Group Department of Computer Science ETH Zürich Systems Programming and Computer Architecture (252-6-) Timothy Roscoe Herbstsemester 26 AS 26 Virtual Memory 8: Virtual Memory Computer Architecture

More information

VM as a cache for disk

VM as a cache for disk Virtualization Virtual Memory Computer Systems Organization (Spring 2017) CSCI-UA 201, Section 3 Instructor: Joanna Klukowska Virtualization of a resource: presenting a user with a different view of that

More information

198:231 Intro to Computer Organization. 198:231 Introduction to Computer Organization Lecture 14

198:231 Intro to Computer Organization. 198:231 Introduction to Computer Organization Lecture 14 98:23 Intro to Computer Organization Lecture 4 Virtual Memory 98:23 Introduction to Computer Organization Lecture 4 Instructor: Nicole Hynes nicole.hynes@rutgers.edu Credits: Several slides courtesy of

More information

VIRTUAL MEMORY: CONCEPTS

VIRTUAL MEMORY: CONCEPTS VIRTUAL MEMORY: CONCEPTS CS 45 Computer Organization and Architecture Prof. Donald J. Patterson Adapted from Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition VIRTUAL MEMORY:

More information

Virtual Memory. Alan L. Cox Some slides adapted from CMU slides

Virtual Memory. Alan L. Cox Some slides adapted from CMU slides Alan L. Cox alc@rice.edu Some slides adapted from CMU 5.23 slides Objectives Be able to explain the rationale for VM Be able to explain how VM is implemented Be able to translate virtual addresses to physical

More information

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Roadmap. Java: Assembly language: OS: Machine code: Computer system: Roadmap C: car *c = malloc(sizeof(car)); c->miles = ; c->gals = 7; float mpg = get_mpg(c); free(c); Assembly language: Machine code: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp %rbp Java: Car c = new

More information

Virtual Memory II CSE 351 Spring

Virtual Memory II CSE 351 Spring Virtual Memory II CSE 351 Spring 2018 https://xkcd.com/1495/ Virtual Memory (VM) Overview and motivation VM as a tool for caching Address translation VM as a tool for memory management VM as a tool for

More information

Foundations of Computer Systems

Foundations of Computer Systems 8-6 Foundations of Computer Systems Lecture 5: Virtual Memory Concepts and Systems October 8, 27 8-6 SE PL OS CA Required Reading Assignment: Chapter 9 of CS:APP (3 rd edition) by Randy Bryant & Dave O

More information

University of Washington Virtual memory (VM)

University of Washington Virtual memory (VM) Virtual memory (VM) Overview and mo-va-on VM as tool for caching VM as tool for memory management VM as tool for memory protec-on Address transla-on Processes Defini=on: A process is an instance of a running

More information

Virtual Memory II. CSE 351 Autumn Instructor: Justin Hsia

Virtual Memory II. CSE 351 Autumn Instructor: Justin Hsia Virtual Memory II CSE 35 Autumn 26 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun https://xkcd.com/495/

More information

Virtual Memory II. CSE 351 Autumn Instructor: Justin Hsia

Virtual Memory II. CSE 351 Autumn Instructor: Justin Hsia Virtual Memory II CSE 35 Autumn 27 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan https://xkcd.com/495/

More information

Virtual Memory. Computer Systems Principles

Virtual Memory. Computer Systems Principles Virtual Memory Computer Systems Principles Objectives Virtual Memory What is it? How does it work? Virtual Memory Address Translation /7/25 CMPSCI 23 - Computer Systems Principles 2 Problem Lots of executing

More information

Virtual Memory. Physical Addressing. Problem 2: Capacity. Problem 1: Memory Management 11/20/15

Virtual Memory. Physical Addressing. Problem 2: Capacity. Problem 1: Memory Management 11/20/15 Memory Addressing Motivation: why not direct physical memory access? Address translation with pages Optimizing translation: translation lookaside buffer Extra benefits: sharing and protection Memory as

More information

Virtual Memory. Samira Khan Apr 27, 2017

Virtual Memory. Samira Khan Apr 27, 2017 Virtual Memory Samira Khan Apr 27, 27 Virtual Memory Idea: Give the programmer the illusion of a large address space while having a small physical memory So that the programmer does not worry about managing

More information

CSE 351. Virtual Memory

CSE 351. Virtual Memory CSE 351 Virtual Memory Virtual Memory Very powerful layer of indirection on top of physical memory addressing We never actually use physical addresses when writing programs Every address, pointer, etc

More information

Virtual Memory Oct. 29, 2002

Virtual Memory Oct. 29, 2002 5-23 The course that gives CMU its Zip! Virtual Memory Oct. 29, 22 Topics Motivations for VM Address translation Accelerating translation with TLBs class9.ppt Motivations for Virtual Memory Use Physical

More information

Virtual Memory. Motivations for VM Address translation Accelerating translation with TLBs

Virtual Memory. Motivations for VM Address translation Accelerating translation with TLBs Virtual Memory Today Motivations for VM Address translation Accelerating translation with TLBs Fabián Chris E. Bustamante, Riesbeck, Fall Spring 2007 2007 A system with physical memory only Addresses generated

More information

Virtual Memory I. CSE 351 Spring Instructor: Ruth Anderson

Virtual Memory I. CSE 351 Spring Instructor: Ruth Anderson Virtual Memory I CSE 35 Spring 27 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Midterms Graded If you did

More information

virtual memory. March 23, Levels in Memory Hierarchy. DRAM vs. SRAM as a Cache. Page 1. Motivation #1: DRAM a Cache for Disk

virtual memory. March 23, Levels in Memory Hierarchy. DRAM vs. SRAM as a Cache. Page 1. Motivation #1: DRAM a Cache for Disk 5-23 March 23, 2 Topics Motivations for VM Address translation Accelerating address translation with TLBs Pentium II/III system Motivation #: DRAM a Cache for The full address space is quite large: 32-bit

More information

A Few Problems with Physical Addressing. Virtual Memory Process Abstraction, Part 2: Private Address Space

A Few Problems with Physical Addressing. Virtual Memory Process Abstraction, Part 2: Private Address Space Process Abstraction, Part : Private Motivation: why not direct physical memory access? Address translation with pages Optimizing translation: translation lookaside buffer Extra benefits: sharing and protection

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2018 Lecture 24 LAST TIME Extended virtual memory concept to be a cache of memory stored on disk DRAM becomes L4 cache of data stored on L5 disk Extend page

More information

CISC 360. Virtual Memory Dec. 4, 2008

CISC 360. Virtual Memory Dec. 4, 2008 CISC 36 Virtual Dec. 4, 28 Topics Motivations for VM Address translation Accelerating translation with TLBs Motivations for Virtual Use Physical DRAM as a Cache for the Disk Address space of a process

More information

Motivations for Virtual Memory Virtual Memory Oct. 29, Why VM Works? Motivation #1: DRAM a Cache for Disk

Motivations for Virtual Memory Virtual Memory Oct. 29, Why VM Works? Motivation #1: DRAM a Cache for Disk class8.ppt 5-23 The course that gives CMU its Zip! Virtual Oct. 29, 22 Topics Motivations for VM Address translation Accelerating translation with TLBs Motivations for Virtual Use Physical DRAM as a Cache

More information

CS 153 Design of Operating Systems

CS 153 Design of Operating Systems CS 153 Design of Operating Systems Spring 18 Lectre 17: Advanced Paging Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Some slides modified from originals

More information

virtual memory Page 1 CSE 361S Disk Disk

virtual memory Page 1 CSE 361S Disk Disk CSE 36S Motivations for Use DRAM a for the Address space of a process can exceed physical memory size Sum of address spaces of multiple processes can exceed physical memory Simplify Management 2 Multiple

More information

Virtual Memory Nov 9, 2009"

Virtual Memory Nov 9, 2009 Virtual Memory Nov 9, 2009" Administrivia" 2! 3! Motivations for Virtual Memory" Motivation #1: DRAM a Cache for Disk" SRAM" DRAM" Disk" 4! Levels in Memory Hierarchy" cache! virtual memory! CPU" regs"

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 205 Lecture 23 LAST TIME: VIRTUAL MEMORY! Began to focus on how to virtualize memory! Instead of directly addressing physical memory, introduce a level of

More information

@2010 Badri Computer Architecture Assembly II. Virtual Memory. Topics (Chapter 9) Motivations for VM Address translation

@2010 Badri Computer Architecture Assembly II. Virtual Memory. Topics (Chapter 9) Motivations for VM Address translation Virtual Memory Topics (Chapter 9) Motivations for VM Address translation 1 Motivations for Virtual Memory Use Physical DRAM as a Cache for the Disk Address space of a process can exceed physical memory

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 208 Lecture 23 LAST TIME: VIRTUAL MEMORY Began to focus on how to virtualize memory Instead of directly addressing physical memory, introduce a level of indirection

More information

Virtual Memory: Systems

Virtual Memory: Systems Virtual Memory: Systems 5-23: Introduction to Computer Systems 8 th Lecture, March 28, 27 Instructor: Franz Franchetti & Seth Copen Goldstein Recap: Hmmm, How Does This Work?! Process Process 2 Process

More information

Random-Access Memory (RAM) Systemprogrammering 2007 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics

Random-Access Memory (RAM) Systemprogrammering 2007 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics Systemprogrammering 27 Föreläsning 4 Topics The memory hierarchy Motivations for VM Address translation Accelerating translation with TLBs Random-Access (RAM) Key features RAM is packaged as a chip. Basic

More information

Random-Access Memory (RAM) Systemprogrammering 2009 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics! The memory hierarchy

Random-Access Memory (RAM) Systemprogrammering 2009 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics! The memory hierarchy Systemprogrammering 29 Föreläsning 4 Topics! The memory hierarchy! Motivations for VM! Address translation! Accelerating translation with TLBs Random-Access (RAM) Key features! RAM is packaged as a chip.!

More information

P6/Linux Memory System Nov 11, 2009"

P6/Linux Memory System Nov 11, 2009 P6/Linux Memory System Nov 11, 2009" REMEMBER" 2! 3! Intel P6" P6 Memory System" DRAM" external system bus (e.g. PCI)" L2" cache" cache bus! bus interface unit" inst" TLB" instruction" fetch unit" L1"

More information

Virtual Memory: Systems

Virtual Memory: Systems Virtual Memory: Systems 5-23 / 8-23: Introduc2on to Computer Systems 7 th Lecture, Mar. 22, 22 Instructors: Todd C. Mowry & Anthony Rowe Today Virtual memory ques7ons and answers Simple memory system example

More information

18-447: Computer Architecture Lecture 16: Virtual Memory

18-447: Computer Architecture Lecture 16: Virtual Memory 18-447: Computer Architecture Lecture 16: Virtual Memory Justin Meza Carnegie Mellon University (with material from Onur Mutlu, Michael Papamichael, and Vivek Seshadri) 1 Notes HW 2 and Lab 2 grades will

More information

CS 261 Fall Mike Lam, Professor. Virtual Memory

CS 261 Fall Mike Lam, Professor. Virtual Memory CS 261 Fall 2016 Mike Lam, Professor Virtual Memory Topics Operating systems Address spaces Virtual memory Address translation Memory allocation Lingering questions What happens when you call malloc()?

More information

Virtual Memory I. CSE 351 Winter Instructor: Mark Wyse

Virtual Memory I. CSE 351 Winter Instructor: Mark Wyse http://rebrn.com/re/bad-chrome-6282/ Virtual Memory I CSE 35 Winter 28 Instructor: Mark Wyse Teaching Assistants: Kevin Bi Parker DeWilde Emily Furst Sarah House Waylon Huang Vinny Palaniappan Administrative

More information

PROCESS VIRTUAL MEMORY PART 2. CS124 Operating Systems Winter , Lecture 19

PROCESS VIRTUAL MEMORY PART 2. CS124 Operating Systems Winter , Lecture 19 PROCESS VIRTUAL MEMORY PART 2 CS24 Operating Systems Winter 25-26, Lecture 9 2 Virtual Memory Abstraction Last time, officially introduced concept of virtual memory Programs use virtual addresses to refer

More information

Memory System Case Studies Oct. 13, 2008

Memory System Case Studies Oct. 13, 2008 Topics 15-213 Memory System Case Studies Oct. 13, 2008 P6 address translation x86-64 extensions Linux memory management Linux page fault handling Memory mapping Class15+.ppt Intel P6 (Bob Colwell s Chip,

More information

Pentium/Linux Memory System March 17, 2005

Pentium/Linux Memory System March 17, 2005 15-213 The course that gives CMU its Zip! Topics Pentium/Linux Memory System March 17, 2005 P6 address translation x86-64 extensions Linux memory management Linux page fault handling Memory mapping 17-linuxmem.ppt

More information

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. November 15, MIT Fall 2018 L20-1

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. November 15, MIT Fall 2018 L20-1 Virtual Memory Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. L20-1 Reminder: Operating Systems Goals of OS: Protection and privacy: Processes cannot access each other s data Abstraction:

More information

CSE 560 Computer Systems Architecture

CSE 560 Computer Systems Architecture This Unit: CSE 560 Computer Systems Architecture App App App System software Mem I/O The operating system () A super-application Hardware support for an Page tables and address translation s and hierarchy

More information

CS 61C: Great Ideas in Computer Architecture. Lecture 23: Virtual Memory. Bernhard Boser & Randy Katz

CS 61C: Great Ideas in Computer Architecture. Lecture 23: Virtual Memory. Bernhard Boser & Randy Katz CS 61C: Great Ideas in Computer Architecture Lecture 23: Virtual Memory Bernhard Boser & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Agenda Virtual Memory Paged Physical Memory Swap Space Page Faults

More information

CS 61C: Great Ideas in Computer Architecture. Lecture 23: Virtual Memory

CS 61C: Great Ideas in Computer Architecture. Lecture 23: Virtual Memory CS 61C: Great Ideas in Computer Architecture Lecture 23: Virtual Memory Krste Asanović & Randy H. Katz http://inst.eecs.berkeley.edu/~cs61c/fa17 1 Agenda Virtual Memory Paged Physical Memory Swap Space

More information

CSE 120 Principles of Operating Systems

CSE 120 Principles of Operating Systems CSE 120 Principles of Operating Systems Spring 2018 Lecture 10: Paging Geoffrey M. Voelker Lecture Overview Today we ll cover more paging mechanisms: Optimizations Managing page tables (space) Efficient

More information

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1 Memory Allocation Copyright : University of Illinois CS 241 Staff 1 Recap: Virtual Addresses A virtual address is a memory address that a process uses to access its own memory Virtual address actual physical

More information

Virtual Memory: From Address Translation to Demand Paging

Virtual Memory: From Address Translation to Demand Paging Constructive Computer Architecture Virtual Memory: From Address Translation to Demand Paging Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology November 12, 2014

More information

Computer Architecture Lecture 13: Virtual Memory II

Computer Architecture Lecture 13: Virtual Memory II 18-447 Computer Architecture Lecture 13: Virtual Memory II Lecturer: Rachata Ausavarungnirun Carnegie Mellon University Spring 2014, 2/17/2014 (with material from Onur Mutlu, Justin Meza and Yoongu Kim)

More information

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. April 12, 2018 L16-1

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. April 12, 2018 L16-1 Virtual Memory Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. L16-1 Reminder: Operating Systems Goals of OS: Protection and privacy: Processes cannot access each other s data Abstraction:

More information

Chapter 8. Virtual Memory

Chapter 8. Virtual Memory Operating System Chapter 8. Virtual Memory Lynn Choi School of Electrical Engineering Motivated by Memory Hierarchy Principles of Locality Speed vs. size vs. cost tradeoff Locality principle Spatial Locality:

More information

Memory Management! How the hardware and OS give application pgms:" The illusion of a large contiguous address space" Protection against each other"

Memory Management! How the hardware and OS give application pgms: The illusion of a large contiguous address space Protection against each other Memory Management! Goals of this Lecture! Help you learn about:" The memory hierarchy" Spatial and temporal locality of reference" Caching, at multiple levels" Virtual memory" and thereby " How the hardware

More information

Memory Management! Goals of this Lecture!

Memory Management! Goals of this Lecture! Memory Management! Goals of this Lecture! Help you learn about:" The memory hierarchy" Why it works: locality of reference" Caching, at multiple levels" Virtual memory" and thereby " How the hardware and

More information

Memory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources

Memory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources Memory Management Topics CS 537 Lecture Memory Michael Swift Goals of memory management convenient abstraction for programming isolation between processes allocate scarce memory resources between competing

More information

Virtual Memory. Spring Instructors: Aykut and Erkut Erdem

Virtual Memory. Spring Instructors: Aykut and Erkut Erdem Virtual Memory Spring 22 Instructors: Aykut and Erkut Erdem Acknowledgement: The course slides are adapted from the slides prepared by R.E. Bryant, D.R. O Hallaron, G. Kesden and Markus Püschel of Carnegie-

More information

CS 5523 Operating Systems: Memory Management (SGG-8)

CS 5523 Operating Systems: Memory Management (SGG-8) CS 5523 Operating Systems: Memory Management (SGG-8) Instructor: Dr Tongping Liu Thank Dr Dakai Zhu, Dr Palden Lama, and Dr Tim Richards (UMASS) for providing their slides Outline Simple memory management:

More information

Memory Management. Goals of this Lecture. Motivation for Memory Hierarchy

Memory Management. Goals of this Lecture. Motivation for Memory Hierarchy Memory Management Goals of this Lecture Help you learn about: The memory hierarchy Spatial and temporal locality of reference Caching, at multiple levels Virtual memory and thereby How the hardware and

More information

18-447: Computer Architecture Lecture 18: Virtual Memory III. Yoongu Kim Carnegie Mellon University Spring 2013, 3/1

18-447: Computer Architecture Lecture 18: Virtual Memory III. Yoongu Kim Carnegie Mellon University Spring 2013, 3/1 18-447: Computer Architecture Lecture 18: Virtual Memory III Yoongu Kim Carnegie Mellon University Spring 2013, 3/1 Upcoming Schedule Today: Lab 3 Due Today: Lecture/Recitation Monday (3/4): Lecture Q&A

More information

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory.

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory. Virtual Memory 1 Learning Outcomes An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory. 2 Memory Management Unit (or TLB) The position and function

More information

Virtual Memory. CS 3410 Computer System Organization & Programming

Virtual Memory. CS 3410 Computer System Organization & Programming Virtual Memory CS 3410 Computer System Organization & Programming These slides are the product of many rounds of teaching CS 3410 by Professors Weatherspoon, Bala, Bracy, and Sirer. Where are we now and

More information

Virtual Memory. Patterson & Hennessey Chapter 5 ELEC 5200/6200 1

Virtual Memory. Patterson & Hennessey Chapter 5 ELEC 5200/6200 1 Virtual Memory Patterson & Hennessey Chapter 5 ELEC 5200/6200 1 Virtual Memory Use main memory as a cache for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs

More information

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory.

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory. Virtual Memory Learning Outcomes An understanding of page-based virtual memory in depth. Including the R000 s support for virtual memory. Memory Management Unit (or TLB) The position and function of the

More information

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

Memory Hierarchy. Goal: Fast, unlimited storage at a reasonable cost per bit. Memory Hierarchy Goal: Fast, unlimited storage at a reasonable cost per bit. Recall the von Neumann bottleneck - single, relatively slow path between the CPU and main memory. Fast: When you need something

More information

Virtual Memory. 1 Administrivia. Tom Kelliher, CS 240. May. 1, Announcements. Homework, toolboxes due Friday. Assignment.

Virtual Memory. 1 Administrivia. Tom Kelliher, CS 240. May. 1, Announcements. Homework, toolboxes due Friday. Assignment. Virtual Memory Tom Kelliher, CS 240 May. 1, 2002 1 Administrivia Announcements Homework, toolboxes due Friday. Assignment From Last Time Introduction to caches. Outline 1. Virtual memory. 2. System support:

More information

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 Memory Management Disclaimer: some slides are adopted from book authors slides with permission 1 CPU management Roadmap Process, thread, synchronization, scheduling Memory management Virtual memory Disk

More information

Lecture 21: Virtual Memory. Spring 2018 Jason Tang

Lecture 21: Virtual Memory. Spring 2018 Jason Tang Lecture 21: Virtual Memory Spring 2018 Jason Tang 1 Topics Virtual addressing Page tables Translation lookaside buffer 2 Computer Organization Computer Processor Memory Devices Control Datapath Input Output

More information

Chapter 5B. Large and Fast: Exploiting Memory Hierarchy

Chapter 5B. Large and Fast: Exploiting Memory Hierarchy Chapter 5B Large and Fast: Exploiting Memory Hierarchy One Transistor Dynamic RAM 1-T DRAM Cell word access transistor V REF TiN top electrode (V REF ) Ta 2 O 5 dielectric bit Storage capacitor (FET gate,

More information

Address Translation. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Address Translation. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University Address Translation Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics How to reduce the size of page tables? How to reduce the time for

More information

P6 memory system P6/Linux Memory System October 31, Overview of P6 address translation. Review of abbreviations. Topics. Symbols: ...

P6 memory system P6/Linux Memory System October 31, Overview of P6 address translation. Review of abbreviations. Topics. Symbols: ... 15-213 P6/Linux ory System October 31, 00 Topics P6 address translation Linux memory management Linux fault handling memory mapping DRAM bus interface unit instruction fetch unit processor package P6 memory

More information

John Wawrzynek & Nick Weaver

John Wawrzynek & Nick Weaver CS 61C: Great Ideas in Computer Architecture Lecture 23: Virtual Memory John Wawrzynek & Nick Weaver http://inst.eecs.berkeley.edu/~cs61c From Previous Lecture: Operating Systems Input / output (I/O) Memory

More information

Intel P The course that gives CMU its Zip! P6/Linux Memory System November 1, P6 memory system. Review of abbreviations

Intel P The course that gives CMU its Zip! P6/Linux Memory System November 1, P6 memory system. Review of abbreviations 15-213 The course that gives CMU its Zip! P6/Linux ory System November 1, 01 Topics P6 address translation Linux memory management Linux fault handling memory mapping Intel P6 Internal Designation for

More information

Intel P6 (Bob Colwell s Chip, CMU Alumni) The course that gives CMU its Zip! Memory System Case Studies November 7, 2007.

Intel P6 (Bob Colwell s Chip, CMU Alumni) The course that gives CMU its Zip! Memory System Case Studies November 7, 2007. class.ppt 15-213 The course that gives CMU its Zip! ory System Case Studies November 7, 07 Topics P6 address translation x86-64 extensions Linux memory management Linux fault handling ory mapping Intel

More information

Memory Hierarchy. Mehran Rezaei

Memory Hierarchy. Mehran Rezaei Memory Hierarchy Mehran Rezaei What types of memory do we have? Registers Cache (Static RAM) Main Memory (Dynamic RAM) Disk (Magnetic Disk) Option : Build It Out of Fast SRAM About 5- ns access Decoders

More information

Memory Hierarchy Requirements. Three Advantages of Virtual Memory

Memory Hierarchy Requirements. Three Advantages of Virtual Memory CS61C L12 Virtual (1) CS61CL : Machine Structures Lecture #12 Virtual 2009-08-03 Jeremy Huddleston Review!! Cache design choices: "! Size of cache: speed v. capacity "! size (i.e., cache aspect ratio)

More information

Virtual Memory. CS 351: Systems Programming Michael Saelee

Virtual Memory. CS 351: Systems Programming Michael Saelee Virtual Memory CS 351: Systems Programming Michael Saelee registers cache (SRAM) main memory (DRAM) local hard disk drive (HDD/SSD) remote storage (networked drive / cloud) previously: SRAM

More information

CS 318 Principles of Operating Systems

CS 318 Principles of Operating Systems CS 318 Principles of Operating Systems Fall 2018 Lecture 10: Virtual Memory II Ryan Huang Slides adapted from Geoff Voelker s lectures Administrivia Next Tuesday project hacking day No class My office

More information

Virtual Memory. CS 3410 Computer System Organization & Programming. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon]

Virtual Memory. CS 3410 Computer System Organization & Programming. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon] Virtual Memory CS 3410 Computer System Organization & Programming [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon] Click any letter let me know you re here today. Instead of a DJ Clicker Question today,

More information

Virtual Memory: From Address Translation to Demand Paging

Virtual Memory: From Address Translation to Demand Paging Constructive Computer Architecture Virtual Memory: From Address Translation to Demand Paging Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology November 9, 2015

More information

University*of*Washington*

University*of*Washington* Roadmap C: car c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp

More information

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory Recall: Address Space Map 13: Memory Management Biggest Virtual Address Stack (Space for local variables etc. For each nested procedure call) Sometimes Reserved for OS Stack Pointer Last Modified: 6/21/2004

More information

Another View of the Memory Hierarchy. Lecture #25 Virtual Memory I Memory Hierarchy Requirements. Memory Hierarchy Requirements

Another View of the Memory Hierarchy. Lecture #25 Virtual Memory I Memory Hierarchy Requirements. Memory Hierarchy Requirements CS61C L25 Virtual I (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #25 Virtual I 27-8-7 Scott Beamer, Instructor Another View of the Hierarchy Thus far{ Next: Virtual { Regs Instr.

More information

CSE 120 Principles of Operating Systems Spring 2017

CSE 120 Principles of Operating Systems Spring 2017 CSE 120 Principles of Operating Systems Spring 2017 Lecture 12: Paging Lecture Overview Today we ll cover more paging mechanisms: Optimizations Managing page tables (space) Efficient translations (TLBs)

More information

VIRTUAL MEMORY II. Jo, Heeseung

VIRTUAL MEMORY II. Jo, Heeseung VIRTUAL MEMORY II Jo, Heeseung TODAY'S TOPICS How to reduce the size of page tables? How to reduce the time for address translation? 2 PAGE TABLES Space overhead of page tables The size of the page table

More information

Recap: Memory Management

Recap: Memory Management , 4/13/2018 EE445M/EE360L.12 Embedded and Real-Time Systems/ Real-Time Operating Systems : Memory Protection, Virtual Memory, Paging References: T. Anderson, M. Dahlin, Operating Systems: Principles and

More information

CIS Operating Systems Memory Management Cache and Demand Paging. Professor Qiang Zeng Spring 2018

CIS Operating Systems Memory Management Cache and Demand Paging. Professor Qiang Zeng Spring 2018 CIS 3207 - Operating Systems Memory Management Cache and Demand Paging Professor Qiang Zeng Spring 2018 Process switch Upon process switch what is updated in order to assist address translation? Contiguous

More information

CS252 S05. Main memory management. Memory hardware. The scale of things. Memory hardware (cont.) Bottleneck

CS252 S05. Main memory management. Memory hardware. The scale of things. Memory hardware (cont.) Bottleneck Main memory management CMSC 411 Computer Systems Architecture Lecture 16 Memory Hierarchy 3 (Main Memory & Memory) Questions: How big should main memory be? How to handle reads and writes? How to find

More information

Virtual Memory. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Virtual Memory. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University Virtual Memory Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) Virtual Memory:

More information

CS162 Operating Systems and Systems Programming Lecture 10 Caches and TLBs"

CS162 Operating Systems and Systems Programming Lecture 10 Caches and TLBs CS162 Operating Systems and Systems Programming Lecture 10 Caches and TLBs" October 1, 2012! Prashanth Mohan!! Slides from Anthony Joseph and Ion Stoica! http://inst.eecs.berkeley.edu/~cs162! Caching!

More information

Computer Science 146. Computer Architecture

Computer Science 146. Computer Architecture Computer Architecture Spring 2004 Harvard University Instructor: Prof. dbrooks@eecs.harvard.edu Lecture 18: Virtual Memory Lecture Outline Review of Main Memory Virtual Memory Simple Interleaving Cycle

More information