Week 5:Virtual Memory CS 162. Today’s Section Administrivia Quiz Review of Lecture Worksheet and Discussion.

Slides:



Advertisements
Similar presentations
1 Lecture 13: Cache and Virtual Memroy Review Cache optimization approaches, cache miss classification, Adapted from UCB CS252 S01.
Advertisements

Paging 1 CS502 Spring 2006 Paging CS-502 Operating Systems.
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.
1 A Real Problem  What if you wanted to run a program that needs more memory than you have?
Cs 325 virtualmemory.1 Accessing Caches in Virtual Memory Environment.
COMP 3221: Microprocessors and Embedded Systems Lectures 27: Virtual Memory - III Lecturer: Hui Wu Session 2, 2005 Modified.
CS 153 Design of Operating Systems Spring 2015
Misc Exercise 2 updated with Part III.  Due on next Tuesday 12:30pm. Project 2 (Suggestion)  Write a small test for each call.  Start from file system.
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
CAS3SH3 Final Review. The Final Tue 28 th, 7pm, IWC3 closed book, closed note Non-comprehensive: memory management, storage & file system Types of questions:
Spring 2003CSE P5481 Introduction Why memory subsystem design is important CPU speeds increase 55% per year DRAM speeds increase 3% per year rate of increase.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
CSCE 212 Chapter 7 Memory Hierarchy Instructor: Jason D. Bakos.
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
1 COMP 206: Computer Architecture and Implementation Montek Singh Mon, Oct 31, 2005 Topic: Memory Hierarchy Design (HP3 Ch. 5) (Caches, Main Memory and.
ECE 232 L27.Virtual.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 27 Virtual.
ENGS 116 Lecture 121 Caches Vincent H. Berk Wednesday October 29 th, 2008 Reading for Friday: Sections C.1 – C.3 Article for Friday: Jouppi Reading for.
CS-3013 & CS-502 Summer 2006 Paging1 CS-3013 & CS-502 Summer 2006.
Memory Management April 28, 2000 Instructor: Gary Kimura.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 346, Royden, Operating System Concepts Operating Systems Lecture 24 Paging.
Lecture 21 Last lecture Today’s lecture Cache Memory Virtual memory
Review of Memory Management, Virtual Memory CS448.
Computer Architecture Lecture 28 Fasih ur Rehman.
Lecture 19: Virtual Memory
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
3-May-2006cse cache © DW Johnson and University of Washington1 Cache Memory CSE 410, Spring 2006 Computer Systems
Virtual Memory. DRAM as cache What about programs larger than DRAM? When we run multiple programs, all must fit in DRAM! Add another larger, slower level.
1  1998 Morgan Kaufmann Publishers Recap: Memory Hierarchy of a Modern Computer System By taking advantage of the principle of locality: –Present the.
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
CS162 Operating Systems and Systems Programming Lecture 13 Caches and TLBs March 12, 2008 Prof. Anthony D. Joseph
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?
Review °Apply Principle of Locality Recursively °Manage memory to disk? Treat as cache Included protection as bonus, now critical Use Page Table of mappings.
Operating Systems Unit 7: – Virtual Memory organization Operating Systems.
Paging (continued) & Caching CS-3013 A-term Paging (continued) & Caching CS-3013 Operating Systems A-term 2008 (Slides include materials from Modern.
4.3 Virtual Memory. Virtual memory  Want to run programs (code+stack+data) larger than available memory.  Overlays programmer divides program into pieces.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
Memory Hierarchy and Caches. Who Cares about Memory Hierarchy? Processor Only Thus Far in Course CPU-DRAM Gap 1980: no cache in µproc; level cache,
CS 162 Discussion Section Week 5 10/7 – 10/11. Today’s Section ●Project discussion (5 min) ●Quiz (5 min) ●Lecture Review (20 min) ●Worksheet and Discussion.
Operating Systems Session 7: – Virtual Memory organization Operating Systems.
CS203 – Advanced Computer Architecture Virtual Memory.
CS 162 Discussion Section Week 6. Administrivia Project 2 Deadlines – Initial Design Due: 3/1 – Review Due: 3/5 – Code Due: 3/15.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 33 Paging Read Ch. 9.4.
CS161 – Design and Architecture of Computer
8 July 2015 Charles Reiss
Virtual Memory Chapter 7.4.
CS161 – Design and Architecture of Computer
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?
Memory Hierarchy Virtual Memory, Address Translation
CSCI206 - Computer Organization & Programming
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
CS162 Operating Systems and Systems Programming Lecture 10 Caches and TLBs February 26, 2014 Anthony D. Joseph
February 23, 2011 Ion Stoica CS162 Operating Systems and Systems Programming Lecture 10 Caches and TLBs February.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Lecture 22: Cache Hierarchies, Memory
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Anthony D. Joseph and Ion Stoica
CSE451 Memory Management Introduction Autumn 2002
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE451 Virtual Memory Paging Autumn 2002
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CS703 - Advanced Operating Systems
Sarah Diesburg Operating Systems CS 3430
4.3 Virtual Memory.
Sarah Diesburg Operating Systems COP 4610
Presentation transcript:

Week 5:Virtual Memory CS 162

Today’s Section Administrivia Quiz Review of Lecture Worksheet and Discussion

Administrivia Project 2 – Initial Design Documents due Next Thursday, March 6 th ! – Get started early, not as straightforward – Signups should be up by this weekend! – Fill out midterm course surveys! – Check out Project 2 Overview for Nachos on Piazza! Midterm 1 is 3/12, 4:00-5:30pm in 245 Li Ka Shing (A-L) and 105 Stanley (M-Z) – Covers lectures 1-12, readings, handouts, projs 1 & 2

LECTURE REVIEW Address Translation and Caching

Address Translation Translation – Changing the virtual address to a physical one Allows the program to think that we have more space than we actually do Provides a way to overlap to share memory between processes if need be

Example of General Address Translation Prog 1 Virtual Address Space 1 Prog 2 Virtual Address Space 2 Code Data Heap Stack Code Data Heap Stack Data 2 Stack 1 Heap 1 OS heap & Stacks Code 1 Stack 2 Data 1 Heap 2 Code 2 OS code OS data Translation Map 1Translation Map 2 Physical Address Space

Issues with Simple Segmentation Method Fragmentation problem – Not every process is the same size – Over time, memory space becomes fragmented Hard to do inter-process sharing – Want to share code segments when possible – Want to share memory between processes – Helped by providing multiple segments per process process 6 process 5 process 2 OS process 6 process 5 OS process 6 process 5 OS process 9 process 6 process 9 OS process 10 process 11

Schematic View of Swapping Q: What if not all processes fit in memory? A: Swapping: Extreme form of Context Switch – In order to make room for next process, some or all of the previous process is moved to disk – This greatly increases the cost of context-switching Desirable alternative? – Some way to keep only active portions of a process in memory at any one time – Need finer granularity control over physical memory

Page Table Types Page Table – Maps a virtual page to a physical page Multi-Level Page Tables – Each part of the address is split apart for each level of the table to get more spread. More memory accesses Inverted Page Table – Hash Table used to map virtual addresses to physical ones Remember a page table has to fit within one page!

9.10 2/24/2014Anthony D. Joseph CS162 ©UCB Spring 2014 Address Translation Comparison AdvantagesDisadvantages SegmentationFast context switching: Segment mapping maintained by CPU External fragmentation Paging (single-level page) No external fragmentation, fast easy allocation Large table size ~ virtual memory Paged segmentation Table size ~ # of pages in virtual memory, fast easy allocation Multiple memory references per page access Two-level pages Inverted TableTable size ~ # of pages in physical memory Hash function more complex

Lec /26/14 Anthony D. Joseph CS162 ©UCB Spring 2014 Caching Concept Cache: a repository for copies that can be accessed more quickly than the original –Make frequent case fast and infrequent case less dominant Caching at different levels –Can cache: memory locations, address translations, pages, file blocks, file names, network routes, etc… Only good if: –Frequent case frequent enough and –Infrequent case not too expensive Important measure: Average Access time = (Hit Rate x Hit Time) + (Miss Rate x Miss Time)

Lec /26/14 Anthony D. Joseph CS162 ©UCB Spring 2014 Why Does Caching Help? Locality! Temporal Locality (Locality in Time): –Keep recently accessed data items closer to processor Spatial Locality (Locality in Space): –Move contiguous blocks to the upper levels Address Space 02 n - 1 Probability of reference Lower Level Memory Upper Level Memory To Processor From Processor Blk X Blk Y

Types of Caches Direct Mapped Cache – Every entry has a direct mapping to it’s place in the cache. If something is mapped to the same place, it gets replaced. N-Way Set Associative Cache – N-way means that there are n things stored at that cache line. Log (base 2) n from Index added to Tag Fully Associative Cache – Same as Set Associative except no index bit. Essentially, the number of ways is equal to cache lines.

Lec /26/14 Anthony D. Joseph CS162 ©UCB Spring 2014 Write through: The information is written both to the block in the cache and to the block in the lower-level memory Write back: The information is written only to the block in the cache. –Modified cache block is written to main memory only when it is replaced –Question is block clean or dirty? Pros and Cons of each? –WT: »PRO: read misses cannot result in writes »CON: processor held up on writes unless writes buffered –WB: »PRO: repeated writes not sent to DRAM processor not held up on writes »CON: More complex Read miss may require writeback of dirty data What Happens on a Write?

Translation Lookaside Buffer (TLB) Essentially, a cache for the Page Table Fixed number of slots containing Page Table Entries meaning you don’t have to go into memory for the Entry. Nowadays, done in parallel with cache! As long as the offset size is the same. For Context Switches, must invalidate all of TLB’s entries.