CS 3204 Operating Systems Godmar Back Lecture 16.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

CS 4284 Systems Capstone Godmar Back Virtual Memory – Paging Techniques.
Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
1 Pintos Project #3 Virtual Memory The following slides were created by Xiaomo Liu and others for CS 3204 Fall And Modified by Nick Ryan for Spring.
CS 4284 Systems Capstone Godmar Back Linking and Loading.
Paging Hardware With TLB
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.
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.
Jaishankar Sundararaman
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.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
X86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
CS533 Concepts of Operating Systems Class 14 Extensible Virtual Memory Management.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
ITEC 325 Lecture 29 Memory(6). Review P2 assigned Exam 2 next Friday Demand paging –Page faults –TLB intro.
CS333 Intro to Operating Systems Jonathan Walpole.
Computer Architecture Lecture 28 Fasih ur Rehman.
CS 3204 Operating Systems Godmar Back Lecture 11.
CS 153 Design of Operating Systems Spring 2015 Lecture 17: Paging.
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
CS 4284 Systems Capstone Godmar Back Virtual Memory – Page Tables.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
Operating Systems ECE344 Ding Yuan Paging Lecture 8: Paging.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
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.
CS 3204 Operating Systems Godmar Back Lecture 15.
CS 4284 Systems Capstone Godmar Back Virtual Memory – Paging Techniques.
Memory Management Fundamentals Virtual Memory. Outline Introduction Motivation for virtual memory Paging – general concepts –Principle of locality, demand.
Virtual Memory 1 1.
4.3 Virtual Memory. Virtual memory  Want to run programs (code+stack+data) larger than available memory.  Overlays programmer divides program into pieces.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Demand Paging.
Processes and Virtual Memory
CS 3204 Operating Systems Godmar Back Lecture 17.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Implementation.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
1 Pintos Virtual Memory Management Project (CS3204 Spring 2006 VT) Yi Ma.
Pintos project 3: Virtual Memory Management
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Fragmentation External Fragmentation – total memory space exists to satisfy.
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.
W4118 Operating Systems Instructor: Junfeng Yang.
Memory: Page Table Structure CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Virtual Memory – Paging Techniques
CS161 – Design and Architecture of Computer
Memory: Page Table Structure
CS161 – Design and Architecture of Computer
Virtual Memory – Page Tables
CS 5204 Operating Systems Linking and Loading Godmar Back.
CSE 153 Design of Operating Systems Winter 2018
Chapter 8: Main Memory.
CS 4284 Systems Capstone Linking and Loading Godmar Back.
Main Memory Background Swapping Contiguous Allocation Paging
Lecture 3: Main Memory.
CS 5204 Operating Systems Lecture 10
Translation Buffers (TLB’s)
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Paging and Segmentation
CS703 - Advanced Operating Systems
CSE 153 Design of Operating Systems Winter 2019
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.
Paging Andrew Whitaker CSE451.
Virtual Memory 1 1.
Presentation transcript:

CS 3204 Operating Systems Godmar Back Lecture 16

2/2/2016CS 3204 Fall Announcements Project 3 Milestone due Friday Oct 24, 11:59pm –No extensions Will return by Monday Project 3 Help Session next Monday 6-8pm –Room TBA – check forum Read book chapters 8 and 9 on memory management Reminder: need to pass 90% of tests of project 2 by the end of the semester to pass the class –All project 2 tests except multi-oom will appear as regression tests in project 3 and 4

Layers in Address Translation 2/2/2016CS 3204 Fall MMU Virtual addressPhysical address TLB Hardware Page Table OS Data Structures (Does not exist if TLB reload is implemented in software) updates access/dirty bitsprovides translations refills TLBupdates PTE adds and updates entries for resident pages retrieves feedback about accesses keeps track of all virtual pages for each process, resident or non-resident

2/2/2016CS 3204 Fall Representing Page Tables Choice impacts speed of access vs size needed to store mapping information: –Simple arrays (PDP-11, VAX) Fast, but required space makes it infeasible for large, non-continuous address spaces –Search trees (aka “hierarchical” or “multi- level” page tables) –Hash table

2/2/2016CS 3204 Fall Two-level Page Table Q.: how many pages are needed in –Minimum case –Worst case? (what is the worst case?) This is the original page design on i386 Next slide provides details on how address bits index tree levels If address space is sparse, interior nodes/paths do not exist (parent contains a NULL) Picture shown shows how tree divides virtual address space The kernel virtual pages that hold the page table information need not be contiguous

2/2/2016CS 3204 Fall Example: x86 Address Translation Two-level page table Source: [IA32-v3] 3.7.1

2/2/2016CS 3204 Fall Example: x86 Page Table Entry Note: if bit 0 is 0 (“page not present”) MMU will ignore bits 1-31 – OS can use those at will

2/2/2016CS 3204 Fall Page Table Management on Linux Interesting history: –Linux was originally x86 only with 32bit physical addresses. Its page table matched the one used by x86 hardware –Since: Linux has been ported to other architectures x86 has grown to support 36bit physical addresses (PAE) – required 3-level page table Linux’s now uses 4-level page table to support 64-bit architectures

2/2/2016CS 3204 Fall Linux Page Tables (2) On x86 – hardware == software –On 32-bit (no PAE) middle directory disappears With four-level, “PUD” page upper directory is added (not shown)

2/2/2016CS 3204 Fall Inverted Page Tables Alternative to multi- level page tables – size is O(physical memory)

2/2/2016CS 3204 Fall Page Tables - Summary Page tables store mapping information from virtual to physical addresses, or to find non-resident pages –Input is: process id, current mode (user/kernel) and kind of access (read/write/execute) TLBs cache such mappings Page tables are consulted when TLB miss occurs –Either all software, or in hardware OS must maintain its page table(s) and, if hardware TLB reload is used, the page table (on x86 aka “page directory + table”) that is consulted by MMU –These two tables may or may not be one and the same The OS page table must have sufficient information to load a page’s content from disk

Virtual Memory Paging Techniques

2/2/2016CS 3204 Fall Demand paging Idea: only keep data in memory that’s being used –Needed for virtualization – don’t use up physical memory for data processes don’t access Requires that actual allocation of physical page frames be delayed until first access Many variations –Lazy loading of text & data, mmapped pages & newly allocated heap pages –Copy-on-write

2/2/2016CS 3204 Fall ustack (1) Lazy Loading kernel ucode (1) kcode kdata kbss kheap 0 C C FFFFFFFF 3 GB 1 GB used free user (1) udata (1) user (1) Pintos loads the first process … P1 Pintos then starts the first process … Process faults because code page is not present … Process faults when touching address in data segment … stack page was allocated eagerly data + code pages are noted in page table, but no physical frame has been allocated

2/2/2016CS 3204 Fall ustack (2) ustack (1) Stack Growth kernel ucode (1) kcode kdata kbss kheap 0 C C FFFFFFFF 3 GB 1 GB used free user (1) udata (1) user (1) Pintos loads the first process … P1 Pintos then starts the first process … Process faults because code page is not present … Process calls recursive function or allocates large local variable page fault at about here

2/2/2016CS 3204 Fall Microscopic View of Stack Growth push $ebp sub $20, $esp push $eax push $ebx push $ebp sub $20, $esp push $eax push $ebx 0x8000 esp = 0x8004 esp = 0x8000 esp = 0x7FEC esp = 0x7FE8 intr0e_stub: … call page_fault() … iret intr0e_stub: … call page_fault() … iret Page Fault! void page_fault() { get fault addr determine if it’s close to user $esp Yes: allocate page frame install page in page table No: terminate process } esp = 0x7FE4 Can resume after page fault (and unless f  eip is changed) this will retry the faulting instruction (here: push $eax) –MMU will walk hardware page table again