Administrivia. - If you didn t get Second test of class mailing list, contact cs240c-staff. Clarification on double counting policy

Similar documents
Multiprogramming on physical memory

Outline. 1 Details of paging. 2 The user-level perspective. 3 Case study: 4.4 BSD 1 / 19

Administrivia. - As before, free extension to midnight if you come to class. - Open book, open notes (but not open notebook computer)

Administrivia. - As before, free extension to midnight if you come to class. - Open book, open notes (but not open notebook computer)

- Goal: Run at memory, not disk speeds. - So, keep that 10% in real memory, the other 90% on disk - How to identify the hot 10%?

Administrivia. Paging. Paging challenges. Working set model. What to fetch. Re-starting instructions. Project 2 due Thursday

1 / 48. # of accesses 3 / Need to save state and resume - Process might have been in the middle of an instruction! - Just needed page or more?

Outline. 1 Paging. 2 Eviction policies. 3 Thrashing. 4 Details of paging. 5 The user-level perspective. 6 Case study: 4.

1 Paging. 2 Eviction policies. 3 Thrashing. 4 Details of paging. 5 The user-level perspective. 6 Case study: 4.4 BSD.

Administrivia. Lab 1 due Friday 12pm. We give will give short extensions to groups that run into trouble. But us:

Protection. - Programmers typically assume machine has enough memory - Sum of sizes of all processes often greater than physical memory 1 / 36

Review: Hardware user/kernel boundary

- Established working set model - Led directly to virtual memory. Protection

Chapter 5: Memory Management

64-bit address spaces

Signal types (some of them) Networks and Operating Systems ( ) Chapter 5: Memory Management. Where do signals come from?

Memory System Case Studies Oct. 13, 2008

Pentium/Linux Memory System March 17, 2005

Outline. 1 Paging. 2 Eviction policies. 3 Thrashing 1 / 28

Virtual Memory. CS 351: Systems Programming Michael Saelee

CS 318 Principles of Operating Systems

Address Translation. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CSE 120 Principles of Operating Systems

Virtual memory Paging

CS5460: Operating Systems Lecture 14: Memory Management (Chapter 8)

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

Computer Structure. X86 Virtual Memory and TLB

CSE 120 Principles of Operating Systems Spring 2017

P6/Linux Memory System Nov 11, 2009"

Virtual Memory: Systems

Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems

VIRTUAL MEMORY II. Jo, Heeseung

virtual memory. March 23, Levels in Memory Hierarchy. DRAM vs. SRAM as a Cache. Page 1. Motivation #1: DRAM a Cache for Disk

Lecture 21: Virtual Memory. Spring 2018 Jason Tang

Recap: Memory Management

Memory Management. Dr. Yingwu Zhu

Intel P6 (Bob Colwell s Chip, CMU Alumni) The course that gives CMU its Zip! Memory System Case Studies November 7, 2007.

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24

Main Points. Address Transla+on Concept. Flexible Address Transla+on. Efficient Address Transla+on

virtual memory Page 1 CSE 361S Disk Disk

Random-Access Memory (RAM) Systemprogrammering 2007 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics

Multi-level Translation. CS 537 Lecture 9 Paging. Example two-level page table. Multi-level Translation Analysis

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

Random-Access Memory (RAM) Systemprogrammering 2009 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics! The memory hierarchy

Lecture 13: Virtual Memory Management. CSC 469H1F Fall 2006 Angela Demke Brown

Lec 22: Interrupts. Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University. Announcements

PROCESS VIRTUAL MEMORY PART 2. CS124 Operating Systems Winter , Lecture 19

Systems Programming and Computer Architecture ( ) Timothy Roscoe

Simple idea 1: load-time linking. Our main questions. Some terminology. Simple idea 2: base + bound register. Protection mechanics.

Intel P The course that gives CMU its Zip! P6/Linux Memory System November 1, P6 memory system. Review of abbreviations

198:231 Intro to Computer Organization. 198:231 Introduction to Computer Organization Lecture 14

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

CS162 Operating Systems and Systems Programming Lecture 12. Address Translation. Page 1

ECE 598 Advanced Operating Systems Lecture 14

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23

Virtual Memory. Today. Segmentation Paging A good, if common example

@2010 Badri Computer Architecture Assembly II. Virtual Memory. Topics (Chapter 9) Motivations for VM Address translation

CS399 New Beginnings. Jonathan Walpole

CMSC 412 Project #4 Virtual Memory Due Friday April 11, 2014, at 5:00pm

P6 memory system P6/Linux Memory System October 31, Overview of P6 address translation. Review of abbreviations. Topics. Symbols: ...

Virtual Memory: Systems

Processes and Virtual Memory Concepts

Virtual Memory 1. To do. q Segmentation q Paging q A hybrid system

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Motivations for Virtual Memory Virtual Memory Oct. 29, Why VM Works? Motivation #1: DRAM a Cache for Disk

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)

Virtual Memory I. Jo, Heeseung

MEMORY MANAGEMENT UNITS

14 May 2012 Virtual Memory. Definition: A process is an instance of a running program

Virtual Memory Oct. 29, 2002

Computer Systems. Virtual Memory. Han, Hwansoo

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

CSE 451: Operating Systems Winter Page Table Management, TLBs and Other Pragmatics. Gary Kimura

Main Memory: Address Translation

CPS 104 Computer Organization and Programming Lecture 20: Virtual Memory

Outline. V Computer Systems Organization II (Honors) (Introductory Operating Systems) Advantages of Multi-level Page Tables

Multi-Process Systems: Memory (2) Memory & paging structures: free frames. Memory & paging structures. Physical memory

Linux Signals and Daemons

Precept 2: PMM / VMM. COS 318: Fall 2017

Anne Bracy CS 3410 Computer Science Cornell University

CS162 - Operating Systems and Systems Programming. Address Translation => Paging"

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory.

Virtual Memory. Virtual Memory

CISC 7310X. C08: Virtual Memory. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/22/2018 CUNY Brooklyn College

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory.

CS 153 Design of Operating Systems Winter 2016

Machines and Virtualization. Systems and Networks Jeff Chase Spring 2006

CS 134: Operating Systems

VIRTUAL MEMORY. Operating Systems 2015 Spring by Euiseong Seo

Foundations of Computer Systems

CPS104 Computer Organization and Programming Lecture 16: Virtual Memory. Robert Wagner

CS 61C: Great Ideas in Computer Architecture. Virtual Memory

The UtePC/Yalnix Memory System

Memory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources

Virtual Memory 1. Virtual Memory

Page Which had internal designation P5

Virtual Memory 1. Virtual Memory

Transcription:

p. 1/19 Administrivia Recently updated class mailing list - If you didn t get Second test of class mailing list, contact cs240c-staff. Clarification on double counting policy - Your class project may coincide with your research or another class project - In general this is fine, even encouraged - But you must tell me (and advisor or instructor of the other class) in advance to make sure I had to move my office hours - Now Monday 10am-12pm

p. 2/19 Multiprogramming on physical memory Makes it hard to allocate space contiguously - Convenient for stack, large data structures, etc. Need fault isolation between processes - (Even Microsoft now seems to believe this... ) Processes can consume more than available memory - Dormant processes (wating for event) still have core images

p. 3/19 Solution: Address Spaces Give each program its own address space Only privileged software can manipulate mappings Isolation is natural - Can t even name other processes memory

p. 4/19 Alternatives Segmentation - Part of each memory reference implicit in segment register segreg offset, limit - By loading segment register code can be relocated - Can enforce protection by restricting segment register loads Language-level protection (Java) - Single address space for different modules - Language enforces isolation Software fault isolation - Instrument compiler output - Checks before every store operation prevents modules from trashing each other

p. 5/19 Paging Divide memory up into small pages Map virtual pages to physical pages - Each process has separate mapping Allow OS to gain control on certain operations - Read-only pages trap to OS on write - Invalid pages trap to OS on write - OS can change mapping and resume application Other features sometimes found: - Hardware can set dirty bit - Control caching of page

p. 6/19 x86 Paging (review) Paging enabled by bits in Normally 4KB pages : points to 4KB page directory Page directory: 1024 PDEs (page directory entries) - Each contains physical address of a page table Page table: 1024 PTEs (page table entries) - Each contains physical address of virtual 4K page - Page table covers 4 MB of Virtual mem INVLPG instruction invalidates page translation - Must tell hardware when page table modified

p. 7/19 Linear Address 31 22 21 12 11 Directory Table Offset 0 12 4 KByte Page 10 Page Directory 10 Page Table Physical Address Directory Entry Page Table Entry 20 32* CR3 (PDBR) 1024 PDE 1024 PTE = 2 20 Pages *32 bits aligned onto a 4 KByte boundary

p. 8/19 x86 Paging Extensions PSE: Page size extensions - Setting bit 7 in PDE make a 4MB translation (no PT) PAE Page address extensions - New 64-bit PTE format allows 36 bits of physical address - Page tables, directories have only 512 entries - Use 4-entry Page-Directory-Pointer Table to regain 2 lost bits - PDE bit 7 allows 2MB translation Long mode PAE - In Long mode, pointers are 64-bits - Extends PAE to map 48 bits of virtual address

p. 9/19 Virtual Address 63 Sign Extend 48 47 39 38 30 Page Map Page Directory Level 4 offset Pointer Offset (PML4) 29 21 Page Directory Offset 20 Page Table Offset 12 11 Physical Page Offset 0 9 9 Page Page Map Directory Page Level 4 Pointer Directory Page Table Table Table Table 9 9 12 4 Kbyte Physical Page PTE 52 PML4E 52 PDPE 52 PDE 52 Physical Address 51 Page Map L4 Base Addr 12 CR3 Why are aren t upper 16 bits of VA used?

p. 10/19 Very different MMU: MIPS Hardware has 64-entry TLB - References to addresses not in TLB trap to kernel Each TLB entry has the following fields: Virtual page, Pid, Page frame, NC, D, V, Global Kernel itself unpaged - All of physical memory contiguously mapped in high VM - Kernel uses these pseudo-physical addresses User TLB fault hander very efficient - Two hardware registers reserved for it - utlb miss handler can itself fault allow paged page tables OS is free to choose page table format!

p. 11/19 64-bit address spaces Straight hierarchical page tables not efficient Solution 1: Guarded page tables [Liedtke] - Omit intermediary tables with only one entry - Add predicate in high level tables, stating the only virtual address range mapped underneath + # bits to skip Solution 2: Hashed page tables - Store Virtual Physical translations in hash table - Table size proportional to physical memory - Clustering makes this more efficient

p. 12/19 Superpages How should OS make use of large mappings - x86 has 2/4MB pages that might be useful - Alpha has even more choices: 8KB, 64KB, 512KB, 4MB Sometimes more pages in L2 cache than TLB entries - Don t want costly TLB misses going to main memory Transparent superpage support [Navarro] - Reserve appropriate physical pages if possible - Promote contiguous pages to superpages - Does complicate evicting (esp. dirty pages) demote

p. 13/19 OS policy choices (besides page table) Page replacement - Optimal Least soon to be used (impossible) - Least recently used (hard to implement) - Random - Not recently used Direct-mapped physical caches - Virtual Physical mapping can affect performance - Applications can conflict with each other or themselves - Scientific applications benefit if consecutive virtual pages to not conflict in the cache - Many other applications do better with random mapping

p. 14/19 Paging in day-to-day use Demand paging Growing the stack BSS page allocation Shared text Shared libraries Shared memory Copy-on-write (fork, mmap, etc.) Q: Which pages should have global bit set on x86?

p. 15/19 Example memory layout 4 Gig 0xf000000 USTACKTOP First 256MB physical memory kernel text & most data mapped kernel data Invalid Memory user stack [mmaped regions] break point 0 heap BSS program data program text (read-only) Invalid Memory

p. 16/19 Early VM system calls OS keeps Breakpoint top of heap - Memory regions between breakpoint & stack fault - Set and return new value of breakpoint - Increment value of the breakpoint & return old value Can implement in terms of - But hard to give back physical memory to system

p. 17/19 More VM system calls : OR of PROT_EXEC, PROT_READ, PROT_WRITE, - PROT_NONE : shared/private,... - - Removes memory-mapped object... - Changes protection on pages to or of which pages present - Returns in

p. 18/19 Catching page faults struct sigaction { union { /* signal handler */ void (*sa_handler)(int); void (*sa_sigaction)(int, siginfo_t *, void *); }; sigset_t sa_mask; /* signal mask to apply */ int sa_flags; }; int sigaction (int sig, const struct sigaction *act, struct sigaction *oact) Can specify function to run on

p. 19/19 Example: OpenBSD/i386 siginfo struct sigcontext { int sc_gs; int sc_fs; int sc_es; int sc_ds; int sc_edi; int sc_esi; int sc_ebp; int sc_ebx; int sc_edx; int sc_ecx; int sc_eax; int sc_eip; int sc_cs; /* instruction pointer */ int sc_eflags; /* condition codes, etc. */ int sc_esp; int sc_ss; /* stack pointer */ int sc_onstack; /* sigstack state to restore */ int sc_mask; /* signal mask to restore */ int sc_trapno; int sc_err; };