CS 286: Memory Paging and Virtual Memory

Slides:



Advertisements
Similar presentations
1 Memory hierarchy and paging Electronic Computers M.
Advertisements

Memory Management Paging &Segmentation CS311, CS350 & CS550.
Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.
1 Memory Systems Virtual Memory Lecture 25 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
Virtual Memory Adapted from lecture notes of Dr. Patterson and Dr. Kubiatowicz of UC Berkeley and Rabi Mahapatra & Hank Walker.
Memory Management (II)
Recap. The Memory Hierarchy Increasing distance from the processor in access time L1$ L2$ Main Memory Secondary Memory Processor (Relative) size of the.
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Technical University of Lodz Department of Microelectronics and Computer Science Elements of high performance microprocessor architecture Virtual memory.
Memory Organization.
Chapter 3.2 : Virtual Memory
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
Virtual Memory and Paging J. Nelson Amaral. Large Data Sets Size of address space: – 32-bit machines: 2 32 = 4 GB – 64-bit machines: 2 64 = a huge number.
Computer Organization and Architecture
Memory Management April 28, 2000 Instructor: Gary Kimura.
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
Virtual Memory Chantha Thoeun. Overview  Purpose:  Use the hard disk as an extension of RAM.  Increase the available address space of a process. 
Lecture 21 Last lecture Today’s lecture Cache Memory Virtual memory
Review of Memory Management, Virtual Memory CS448.
Operating Systems Chapter 8
Lecture 19: Virtual Memory
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
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
Memory Management – Page 1 of 49CSCI 4717 – Computer Architecture Memory Management Uni-program – memory split into two parts –One for Operating System.
1 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms.
CS 312 Computer Architecture Memory Basics Department of Computer Science Southern Illinois University Edwardsville Summer, 2015 Dr. Hiroshi Fujinoki
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui COMP 203 / NWEN 201 Computer Organisation / Computer Architectures Virtual.
Fall 2000M.B. Ibáñez Lecture 17 Paging Hardware Support.
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
The Three C’s of Misses 7.5 Compulsory Misses The first time a memory location is accessed, it is always a miss Also known as cold-start misses Only way.
Review °Apply Principle of Locality Recursively °Manage memory to disk? Treat as cache Included protection as bonus, now critical Use Page Table of mappings.
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 Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.
File System Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki CS 314.
Memory Management & Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.
Lecture 11 Virtual Memory
Virtual Memory Chapter 7.4.
ECE232: Hardware Organization and Design
Memory COMPUTER ARCHITECTURE
Memory Management Paging (continued) Segmentation
CS703 - Advanced Operating Systems
Section 9: Virtual Memory (VM)
Memory Hierarchy Virtual Memory, Address Translation
Part V Memory System Design
Memory Management Paging (continued) Segmentation
Computer Architecture
CS399 New Beginnings Jonathan Walpole.
Memory Hierarchy Memory: hierarchy of components of various speeds and capacities Hierarchy driven by cost and performance In early days Primary memory.
CPSC 457 Operating Systems
CSE451 Memory Management Introduction Autumn 2002
Translation Buffers (TLB’s)
Contents Memory types & memory hierarchy Virtual memory (VM)
CS 286 Computer Architecture & Organization
Translation Buffers (TLB’s)
Department of Computer Science
Translation Buffers (TLBs)
Department of Computer Science
Implementation of page-replacement algorithms and Belady’s anomaly
Department of Computer Science
Memory Management Paging (continued) Segmentation
Review What are the advantages/disadvantages of pages versus segments?
4.3 Virtual Memory.
Memory Management & Virtual Memory
Virtual Memory 1 1.
Page Main Memory.
Presentation transcript:

CS 286: Memory Paging and Virtual Memory Virtual Memory – Concepts and Implementation Department of Computer Science Southern Illinois University Edwardsville Fall, 2017 Dr. Hiroshi Fujinoki E-mail: hfujino@siue.edu Virtual_Memory/000

CS 286: Memory Paging and Virtual Memory The problem in memory system Throughput “An improvement rate of 60%/year in microprocessor performance, while the access time to DRAM has been improving at less than 10%/year” “The Gap between Processor and Memory Speeds” by Carlos Carvalho

CS 286: Memory Paging and Virtual Memory Memory Hierarchy CPU Core (ALU) Registers L1 Cache L2 Cache Main Memory Virtual Memory Disk Virtual_Memory/002

CS 286: Memory Paging and Virtual Memory Memory Hierarchy Fastest CPU registers Cache memory within a CPU (Level-1 Cache) Cache memory on a motherboard (Level-2 Cache) Main memory Hard drive Slowest MemoryBasics/006

CS 286: Memory Paging and Virtual Memory We have a trade-off problem Memory Hierarchy Fastest Highest Cost CPU registers Cache memory within a CPU (Level-1 Cache) Cache memory on a motherboard (Level-2 Cache) Main memory Hard drive Slowest Lowest Cost “Cost” = $$$ amount for each byte MemoryBasics/007

Level-1 Cache (Part 2 – Intel’s Pentium 4) CS 286: Memory Paging and Virtual Memory Level-1 Cache (Part 2 – Intel’s Pentium 4) Level-1 (L1) Cache MemoryBasics/009

“External Fragmentation” CS 286: Memory Paging and Virtual Memory Memory External Fragmentation 170MB Physical Memory A 40MB Memory F 30MB A lot of small free-memory spots, but none is big enough A 40MB A 40MB 10MB “External Fragmentation” (unused gap in memory between two programs) B 40MB E 30MB B 40MB E 30MB 10MB 10MB C 40MB C 40MB C 40MB D 40MB D 40MB D 40MB 10MB 10MB 10MB 10MB free 20MB free 30MB free G 30MB Virtual_Memory/001

Solution to these problems CS 286: Memory Paging and Virtual Memory Memory External Fragmentation Problems A lot of small free-memory spots, but none is big enough  The programs must be stopped during compaction  For multi-tasking computers that have a large number of processes, this is VERY expensive  Tight compaction will not allow programs to grow in size This process is called “compaction” Solution to these problems Paging Virtual_Memory/001

CS 286: Memory Paging and Virtual Memory What is virtual memory? 1. It is a mechanism that expands memory space using hard drive 2. It is NOT memory CPU Main Memory 64M Bytes 00000000(16) FFFFFFFFFF(16) Memory Address Space Without virtual memory, memory address space is always same as the amount of main memory Virtual_Memory/003

CS 286: Memory Paging and Virtual Memory What is virtual memory (continued): Disk Virtual Memory Physical Memory Address Space Memory Address Space CPU 00000000(16) FFFFFFFFFF(16) Logical Memory Address Space 64MB Page Main Memory Virtual_Memory/004

CS 286: Memory Paging and Virtual Memory What is virtual memory (summary): 1. It is a mechanism that expands memory space by mapping some of the virtual memory address space to hard drive 2. This implies that a CPU can execute a program that is larger than actual main memory 3. Virtual memory is not memory. It’s just an array of pointers that map pages in virtual address space to the pages in physical address space Virtual_Memory/005

CS 286: Memory Paging and Virtual Memory Implementation of Virtual Memory: Disk CPU Page# Offset 1 2 3 4 5 6 7 8 9 10 Page numbers Valid Flag 1 2 3 4 5 6 3 1 Main Memory Virtual Memory Table Virtual_Memory/006

CS 286: Memory Paging and Virtual Memory What is “offset”? Target memory address CPU Page# Offset Offset 1 2 3 4 5 6 7 8 9 10 Page numbers Valid Flag 1 2 3 4 5 6 3 1 Main Memory Virtual Memory Table Virtual_Memory/006

CS 286: Memory Paging and Virtual Memory If the requested page is in the main memory: 1. Fetch the page# field from the requested address 2. Check the valid flag in the virtual memory table 3. If the valid flag is one (valid), use the page number stored in this slot as the main memory page# 4. Use the offset field as the offset from the beginning of the page Virtual_Memory/007

CS 286: Memory Paging and Virtual Memory Implementation of Virtual Memory: Disk CPU Page# Offset #2 #7 1 2 3 4 5 6 7 8 9 10 Valid Flag 3 1 1 2 3 4 5 6 3 1 This operation is called “page fault” Main Memory Virtual Memory Table Virtual_Memory/008

CS 286: Memory Paging and Virtual Memory If the requested page is not in the main memory: 1. Fetch the page# field from the requested address 2. Check the valid flag in the virtual memory table Called “page fault” 3. If the valid flag of the requested page is zero (invalid), save the destination page in the main memory to hard drive 4. Change the valid flag of the virtual memory that was previously using the memory page to zero (invalid) 5. Load the requested page from HDD to main memory 6. Change the valid field of the requested page to one (valid) Virtual_Memory/009

CS 286: Memory Paging and Virtual Memory Dirty Flag Disk CPU Page# Offset 1 2 3 4 5 6 7 8 9 10 Dirty Flag 3 1 1 2 3 4 5 6 3 Main Memory Valid Flag Virtual Memory Table Virtual_Memory/010

CS 286: Memory Paging and Virtual Memory Dirty Flag  When a new page is loaded to a physical memory page, set its “dirty flag” to ‘0’.  When a physical memory page is updated, set its “dirty flag” to ‘1’. When a physical memory page is being replaced by another virtual memory page, perform one of the followings: If the page’s (the one currently in the physical memory) dirty flag is ‘0 (clean)’: Let a new page to replace the previous one in the physical memory (b) If the page’s (the one currently in the physical memory) dirty flag is ‘1 (dirty)’: Save the current page back to the hard drive, then let a new page to replace the previous one in the physical memory Virtual_Memory/011

CS 286: Memory Paging and Virtual Memory Implementation of Virtual Memory (Continued): Disk CPU CPU Logical Address Page# Offset Translation Lookaside Buffer (TLB) Main Memory 1 2 3 4 5 6 High speed cache within CPU Physical Address Virtual_Memory/012 Virtual Memory Table

CS 286: Memory Paging and Virtual Memory Implementation of Virtual Memory with L2 Cache: Disk CPU Page# Offset Memory Controller Translation Lookaside Buffer Main Memory 1 2 3 4 5 6 CPU L2 Cache Virtual_Memory/013 Virtual Memory Table