Lecture 9: Memory Hierarchy Virtual Memory Kai Bu

Slides:



Advertisements
Similar presentations
Lecture 8: Memory Hierarchy Cache Performance Kai Bu
Advertisements

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.
CSIE30300 Computer Architecture Unit 10: Virtual Memory Hsin-Chou Chi [Adapted from material by and
Virtual Memory Hardware Support
CSC 4250 Computer Architectures December 8, 2006 Chapter 5. Memory Hierarchy.
Memory Management (II)
S.1 Review: The Memory Hierarchy Increasing distance from the processor in access time L1$ L2$ Main Memory Secondary Memory Processor (Relative) size of.
Recap. The Memory Hierarchy Increasing distance from the processor in access time L1$ L2$ Main Memory Secondary Memory Processor (Relative) size of the.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Technical University of Lodz Department of Microelectronics and Computer Science Elements of high performance microprocessor architecture Virtual memory.
Translation Buffers (TLB’s)
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.
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
Virtual Memory I Chapter 8.
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy (Part II)
Operating Systems Chapter 8
Topics covered: Memory subsystem CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Computer Architecture Lecture 28 Fasih ur Rehman.
Some VM Complications Extra memory accesses Page tables are huge
CSE431 L22 TLBs.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 22. Virtual Memory Hardware Support Mary Jane Irwin (
Lecture 19: Virtual Memory
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
July 30, 2001Systems Architecture II1 Systems Architecture II (CS ) Lecture 8: Exploiting Memory Hierarchy: Virtual Memory * Jeremy R. Johnson Monday.
IT253: Computer Organization
Virtual Memory Expanding Memory Multiple Concurrent Processes.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
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?
Lecture 08: Memory Hierarchy Cache Performance Kai Bu
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.
CS.305 Computer Architecture Memory: Virtual Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly made available.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
Protection of Processes Security and privacy of data is challenging currently. Protecting information – Not limited to hardware. – Depends on innovation.
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)
Lectures 8 & 9 Virtual Memory - Paging & Segmentation System Design.
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”
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a “cache” for secondary (disk) storage – Managed jointly.
The Memory Hierarchy Lecture 31 20/07/2009Lecture 31_CA&O_Engr. Umbreen Sabir.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
CS161 – Design and Architecture of Computer
CS 704 Advanced Computer Architecture
CMSC 611: Advanced Computer Architecture
Lecture 11 Virtual Memory
Memory Hierarchy Ideal memory is fast, large, and inexpensive
ECE232: Hardware Organization and Design
Memory COMPUTER ARCHITECTURE
CS161 – Design and Architecture of Computer
Lecture 12 Virtual Memory.
CS 704 Advanced Computer Architecture
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 Chapter 8.
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
CMSC 611: Advanced Computer Architecture
Module 2: Computer-System Structures
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Translation Buffers (TLB’s)
Virtual Memory Overcoming main memory size limitation
Memory Hierarchy Virtual Memory
Translation Buffers (TLB’s)
Module 2: Computer-System Structures
Virtual Memory Lecture notes from MKP and S. Yalamanchili.
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.
Virtual Memory.
Review What are the advantages/disadvantages of pages versus segments?
Virtual Memory.
Virtual Memory 1 1.
Presentation transcript:

Lecture 9: Memory Hierarchy Virtual Memory Kai Bu

Lab 3 Demo due May 13 Report due May 20 Lab 4 Demo due May 20 Report due May 27

Appendix B.4-B.5 some to be revisited in Ch 2

Memory Hierarchy Larger memory for more processes?

Virtual Memory Virtual memory --shares a smaller amount of physical memory among many processes; --divides physical memory into blocks and allocates them to different processes; --automatically manages two levels of memory hierarchy, main memory + secondary storage;

Virtual Memory

Program uses discontiguous memory locations Use secondary/non-memory storage

Virtual Memory Program thinks contiguous memory locations larger physical memory

Virtual Memory relocation allows the same program to run in any location in physical memory

Virtual Memory On program startup OS copies program into RAM; If not enough RAM, OS stops copying program & starts running loaded program segments in RAM; When need un-loaded program segments, OS copies them from disk into RAM; --OS need evict some loaded program segments in RAM; ----OS copies the evicted content back to disk if it is dirty (i.e., has been written into & changed)

Virtual Memory Paged virtual memory page: fixed-size block Segmented virtual memory segment: variable-size block

Virtual Memory Paged virtual memory page address: page # + offset Segmented virtual memory segment address: seg # + offset

Outline Four Memory Hierarchy Questions Address Translation Page Size Selection Virtual Memory Meets Caches Protection & Sharing among Programs

Outline Four Memory Hierarchy Questions Address Translation Page Size Selection Virtual Memory Meets Caches Protection & Sharing among Programs

Four Memory Hierarchy Q’s Q1. Where can a block be placed in main memory? Fully associative strategy OS allows blocks to be placed anywhere in main memory Because of high miss penalty access to a rotating magnetic storage device upon page/address fault

Four Memory Hierarchy Q’s Q2. How is a block found if it is in main memory? use a data structure --contains phy addr of a block; --indexed by page/segment number; in the form of page table --indexed by virtual page number; --table size = the # of pages in the virtual address space

Four Memory Hierarchy Q’s Q2. How is a block found if it is in main memory? Segment addressing add offset to seg’s phy addr; Page addressing concatenate offset to page’s phy addr;

Four Memory Hierarchy Q’s Q3. Which block should be replaced on a virtual memory miss? Least recently used (LRU) block use/reference bit --logically set whenever a page is accessed; --OS periodically clears use bits and later records them to track the least recently referenced pages;

Four Memory Hierarchy Q’s Q4. What happens on a write? Write-back strategy as accessing rotating magnetic disk takes millions of clock cycles; Dirty bit write a block to disk only if it has been altered since being read from the disk;

Outline Four Memory Hierarchy Questions Address Translation Page Size Selection Virtual Memory Meets Caches Protection & Sharing among Programs

Address Translation Page tables are often large and stored in main memory Logically two mem accesses for data access: one to obtain the physical address; one to get the data; Access time doubled How to be faster?

Address Translation Translation lookaside buffer (TLB) /translation buffer (TB) a special cache that keeps address translations TLB entry --tag: portions of the virtual address; --data: a physical page frame number, protection field, valid bit, use bit, dirty bit;

Address Translation Example: Opteron data TLB Steps 1&2: send the virtual address to all tags Step 2: check the type of mem access against protection info in TLB

Address Translation Example: Opteron data TLB Steps 3: the matching tag sends phy addr through multiplexor

Address Translation Example: Opteron data TLB Steps 4: concatenate page offset to phy page frame to form final phy addr

Outline Four Memory Hierarchy Questions Address Translation Page Size Selection Virtual Memory Meets Caches Protection & Sharing among Programs

Page Size Selection Pros of larger page size Smaller page table, less memory (or other resources used for the memory map); Larger cache with fast cache hit; Transferring larger pages to or from secondary storage is more efficient than transferring smaller pages; Map more memory, reduce the number of TLB misses;

Page Size Selection Pros of smaller page size Conserve storage When a contiguous region of virtual memory is not equal in size to a multiple of the page size, a small page size results in less wasted storage. Very large page size may waste more storage, I/O bandwidth and lengthen the time to invoke a process.

Page Size Selection Use both: multiple page sizes Recent microprocessors have decided to support multiple page sizes, mainly because of larger page size reduces the # of TLB entries and thus the # of TLB misses; for some programs, TLB misses can be as significant on CPI as the cache misses;

Outline Four Memory Hierarchy Questions Address Translation Page Size Selection Virtual Memory Meets Caches Protection & Sharing among Programs

Virtual Memory + Caches Cache: virtually indexed + physically tagged

Outline Four Memory Hierarchy Questions Address Translation Page Size Selection Virtual Memory Meets Caches Protection & Sharing among Programs

Multiprogramming Enable a computer to be shared by several programs running concurrently Need protection and sharing among programs

Process A running program plus any state needed to continue running it Time-sharing shares processor and memory with interactive users simultaneously; gives the illusion that all users have their own computers; Process/context switch from one process to another

Process Maintain correct process behavior --computer designer must ensure that the processor portion of the process state can be saved and restored; --OS designer must guarantee that processes do not interfere with each others’ computations; Partition main memory so that several different processes have their state in memory at the same time

Process Protection Proprietary page tables processes can be protected from one another by having their own page tables, each pointing to distinct pages of memory; user programs must be prevented from modifying their page tables

Process Protection Rings added to the processor protection structure, expands memory access protection to multiple levels. The most trusted accesses anything The second most trusted accesses everything except the innermost level … The civilian programs are the least trusted, have the most limited range of accesses.

Process Protection Keys and Locks a program cannot unlock access to the data unless it has the key For keys/capabilities to be useful, hardware and OS must be able to explicitly pass them from one program to another without allowing a program itself to forge them

Example 1: Intel Pentium Segmented virtual memory IA-32: four levels of protection (0) innermost level, kernel mode; (3) outermost level, least privileged mode; separate stacks for each level to avoid security breaches between the levels

Example 1: Intel Pentium Add bounds checking and memory mapping base + limit fields Add sharing and protection global/local address space; a field giving a seg’s legal access level; Add safe calls from user to OS gates and inheriting protection level for parameters call gate

Example 1: Intel Pentium Segment Descriptors

Example 2: 64-bit Opteron Paged virtual memory Multilevel hierarchical page table; Page tables are protected from being written by user programs; Sharing of memory between processes is accomplished by having a page table entry in each address space point to the same physical memory page;

?