CS399 New Beginnings Jonathan Walpole. Virtual Memory (1)

Slides:



Advertisements
Similar presentations
CS 153 Design of Operating Systems Spring 2015
Advertisements

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 11 – Virtual Memory (1)
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management -3 CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent.
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Paging Design.
Translation Buffers (TLB’s)
CS 333 Introduction to Operating Systems Class 9 - Memory Management
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.
Mem. Hier. CSE 471 Aut 011 Evolution in Memory Management Techniques In early days, single program run on the whole machine –Used all the memory available.
Main Memory. Background Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only.
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
CS 333 Introduction to Operating Systems Class 9 - Memory Management Jonathan Walpole Computer Science Portland State University.
CS 241 Section Week #12 (04/22/10).
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Paging. Memory Partitioning Troubles Fragmentation Need for compaction/swapping A process size is limited by the available physical memory Dynamic growth.
CS333 Intro to Operating Systems Jonathan Walpole.
Review of Memory Management, Virtual Memory CS448.
Operating Systems Chapter 8
CS333 Intro to Operating Systems Jonathan Walpole.
CS 153 Design of Operating Systems Spring 2015 Lecture 17: Paging.
Operating Systems ECE344 Ding Yuan Paging Lecture 8: Paging.
IT253: Computer Organization
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
Operating Systems COMP 4850/CISG 5550 Page Tables TLBs Inverted Page Tables Dr. James Money.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui COMP 203 / NWEN 201 Computer Organisation / Computer Architectures Virtual.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-8 Memory Management (2) Department of Computer Science and Software.
Chapter 4 Memory Management Virtual Memory.
Virtual Memory Part 1 Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology May 2, 2012L22-1
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
1 Memory Management. 2 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated) Divide memory into n (possible.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Hardware.
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.
ICOM Noack Memory management Virtual memory Paging and segmentation Demand paging Memory management hardware.
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)
Constructive Computer Architecture Virtual Memory: From Address Translation to Demand Paging Arvind Computer Science & Artificial Intelligence Lab. Massachusetts.
CS203 – Advanced Computer Architecture Virtual Memory.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
Memory Management & Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.
CS161 – Design and Architecture of Computer
Translation Lookaside Buffer
CS161 – Design and Architecture of Computer
Lecture Topics: 11/19 Paging Page tables Memory protection, validation
CS703 - Advanced Operating Systems
Page Table Implementation
Memory Hierarchy Virtual Memory, Address Translation
CS510 Operating System Foundations
Lecture 28: Virtual Memory-Address Translation
CS399 New Beginnings Jonathan Walpole.
Translation Lookaside Buffer
CSE 451: Operating Systems Autumn 2005 Memory Management
Translation Buffers (TLB’s)
TLB Performance Seung Ki Lee.
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
© 2004 Ed Lazowska & Hank Levy
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Translation Buffers (TLB’s)
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Translation Lookaside Buffers
CSE 451: Operating Systems Winter 2005 Page Tables, TLBs, and Other Pragmatics Steve Gribble 1.
Translation Buffers (TLBs)
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Review What are the advantages/disadvantages of pages versus segments?
4.3 Virtual Memory.
Virtual Memory 1 1.
Presentation transcript:

CS399 New Beginnings Jonathan Walpole

Virtual Memory (1)

Page Tables When and why do we access a page table? - On every instruction to translate virtual to physical addresses?

Page Tables When and why do we access a page table? -On every instruction to translate virtual to physical addresses? In Blitz, YES, but in real machines NO! In real machines it is only accessed -On TLB miss faults to refill the TLB -During process creation and destruction -When a process allocates or frees memory?

Translation Lookaside Buffer Problem: MMU can’t keep up with the CPU if it goes to the page table on every memory access!

Translation Lookaside Buffer Solution: -Cache the page table entries in a hardware cache -Small number of entries (e.g., 64) -Each entry contains page number and other stuff from page table entry -Associatively indexed on page number ie. You can do a lookup in a single cycle

Translation Lookaside Buffer CPU po fo page # frame # TLB TLB HitPhysical memory Page Table

Hardware Operation of TLB Page Number Frame Number D R W V unused 50D R W V unused 24D R W V unused 19D R W V unused 6D R W V unused Key Other

Hardware Operation of TLB page numberoffset frame numberoffset Page Number Frame Number D R W V unused 50D R W V unused 24D R W V unused 19D R W V unused 6D R W V unused virtual address physical address 5 37 Key Other

Hardware Operation of TLB page numberoffset frame numberoffset Page Number Frame Number D R W V unused 50D R W V unused 24D R W V unused 19D R W V unused 6D R W V unused physical address 5 37 Key Other virtual address

Hardware Operation of TLB page numberoffset frame numberoffset Page Number Frame Number D R W V unused 50D R W V unused 24D R W V unused 19D R W V unused 6D R W V unused physical address 5 37 Key Other virtual address

Hardware Operation of TLB page numberoffset frame numberoffset Page Number Frame Number D R W V unused 50D R W V unused 24D R W V unused 19D R W V unused 6D R W V unused physical address 5 37 Key Other virtual address

Hardware Operation of TLB page numberoffset frame numberoffset Page Number Frame Number D R W V unused 50D R W V unused 24D R W V unused 19D R W V unused 6D R W V unused physical address 5 37 Key Other virtual address

Software Operation of TLB What if the entry is not in the TLB? -Go look in the page table in memory -Find the right entry -Move it into the TLB -But which TLB entry should be replaced?

Software Operation of TLB Hardware TLB refill -Page tables in specific location and format -TLB hardware handles its own misses -Replacement policy fixed by hardware Software refill -Hardware generates trap (TLB miss fault) -Lets the OS deal with the problem -Page tables become entirely a OS data structure! -Replacement policy managed in software

Software Operation of TLB How can we prevent the next process from using the last process’s address mappings? -Option 1: empty the TLB on context switch New process will generate faults until its pulls enough of its own entries into the TLB -Option 2: just clear the “Valid Bit” on context switch New process will generate faults until its pulls enough of its own entries into the TLB -Option 3: the hardware maintains a process id tag on each TLB entry Hardware compares this to a process id held in a specific register … on every translation

Page Tables Do we access a page table when a process allocates or frees memory?

Page Table Usage Do we access a page table when a process allocates or frees memory? -Not necessarily Library routines (malloc) can service small requests from a pool of free memory already allocated within a process address space When these routines run out of space a new page must be allocated and its entry inserted into the page table -This allocation is requested using a system call

Page Table Design Page table size depends on -Page size -Virtual address length Memory used for page tables is overhead! -How can we save space? … and still find entries quickly? Three options -Single-level page tables -Multi-level page tables -Inverted page tables

Single-Level Page Tables Single-level page table frames in memory page numberoffset 20-bits 12-bits

Single-Level Page Tables Single-level page table frames in memory page numberoffset 20-bits 12-bits

Single-Level Page Tables Single-level page table frames in memory page numberoffset 20-bits 12-bits Problem: requires one page table entry per virtual page!

Single-Level Page Tables Single-level page table frames in memory page numberoffset 20-bits 12-bits 32 bit addresses and 4KB pages means 2 20 page table entries per process

Single-Level Page Tables Single-level page table frames in memory page numberoffset 20-bits 12-bits 64 bit addresses and 4KB pages means 2 52 page table entries per process!

Multi-Level Page Tables Top-level Page table 2nd-level tables frames in memory

Multi-Level Page Tables Top-level Page table 2nd-level tables frames in memory PT1offsetPT2 10-bits 12-bits

Multi-Level Page Tables Top-level Page table 2nd-level tables frames in memory PT1offsetPT2 10-bits 12-bits

Multi-Level Page Tables Top-level Page table 2nd-level tables frames in memory PT1offsetPT2 10-bits 12-bits

Multi-Level Page Tables Top-level Page table 2nd-level tables frames in memory PT1offsetPT2 10-bits 12-bits

Multi-Level Page Tables Top-level Page table 2nd-level tables frames in memory PT1offsetPT2 10-bits 12-bits

Multi-Level Page Tables Top-level Page table 2nd-level tables frames in memory PT1offsetPT2 10-bits 12-bits

Multi-Level Page Tables Ok, but how exactly does this save space?

Multi-Level Page Tables Ok, but how exactly does this save space? Not all pages within a virtual address space are allocated -Not only do they not have a page frame, but that range of virtual addresses is not being used -So no need to maintain complete information about it -Some intermediate page tables are empty and not needed We could also page the page table -This saves space but slows access … a lot!

Address Translation Puzzle