EECS 482 Introduction to Operating Systems

Similar documents
Address spaces and memory management

EECS 482 Introduction to Operating Systems

Memory: Paging System

EECS 482 Introduction to Operating Systems

Operating Systems Virtual Memory. Lecture 11 Michael O Boyle

Lecture 12: Demand Paging

CSE 120 Principles of Operating Systems

CS510 Operating System Foundations. Jonathan Walpole

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

Lecture#16: VM, thrashing, Replacement, Cache state

CS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University

CS 153 Design of Operating Systems Winter 2016

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

3/3/2014! Anthony D. Joseph!!CS162! UCB Spring 2014!

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

CS 550 Operating Systems Spring Memory Management: Page Replacement

CS162 Operating Systems and Systems Programming Lecture 11 Page Allocation and Replacement"

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

CIS Operating Systems Memory Management Cache Replacement & Review. Professor Qiang Zeng Fall 2017

CIS Operating Systems Memory Management Page Replacement. Professor Qiang Zeng Spring 2018

CS 153 Design of Operating Systems Winter 2016

Last Class. Demand Paged Virtual Memory. Today: Demand Paged Virtual Memory. Demand Paged Virtual Memory

All Paging Schemes Depend on Locality. VM Page Replacement. Paging. Demand Paging

MEMORY: SWAPPING. Shivaram Venkataraman CS 537, Spring 2019

Virtual Memory III. Jo, Heeseung

CS370 Operating Systems

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Announcements. Midterm #1. Office Hours Change. Solution on web Must submit requests for re-grades in writing by 3/18/03. Th -> Friday 1-2 PM

Operating Systems. Operating Systems Sina Meraji U of T

Paging and Page Replacement Algorithms

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

CSE 153 Design of Operating Systems

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24

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

1. Overview This project will help you understand address spaces and virtual memory management.

Operating System - Virtual Memory

Virtual Memory Design and Implementation

VIRTUAL MEMORY READING: CHAPTER 9

Reminder: Mechanics of address translation. Paged virtual memory. Reminder: Page Table Entries (PTEs) Demand paging. Page faults

CS 318 Principles of Operating Systems

Basic Memory Management

CS420: Operating Systems

Memory Management. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Virtual Memory. 1 Administrivia. Tom Kelliher, CS 240. May. 1, Announcements. Homework, toolboxes due Friday. Assignment.

Lecture 21: Virtual Memory. Spring 2018 Jason Tang

Memory Management. Virtual Memory. By : Kaushik Vaghani. Prepared By : Kaushik Vaghani

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

Computer Systems II. Memory Management" Subdividing memory to accommodate many processes. A program is loaded in main memory to be executed

Virtual Memory. Virtual Memory. Demand Paging. valid-invalid bit. Virtual Memory Larger than Physical Memory

CS370 Operating Systems

Memory management, part 2: outline

Chapter 9: Virtual Memory

Virtual Memory - II. Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - XVI. University at Buffalo.

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Recap: Memory Management

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 15: Caching: Demand Paged Virtual Memory

Chapter 6: Demand Paging

Virtual Memory Design and Implementation

Virtual Memory Design and Implementation

CSE 120 Principles of Operating Systems

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management

stack Two-dimensional logical addresses Fixed Allocation Binary Page Table

Chapter 9: Virtual Memory

Operating Systems (1DT020 & 1TT802) Lecture 9 Memory Management : Demand paging & page replacement. Léon Mugwaneza

Operating Systems Lecture 6: Memory Management II

CSC Operating Systems Spring Lecture - XIV Virtual Memory - II. Tevfik Ko!ar. Louisiana State University. March 27 th, 2008.

21 Lecture: More VM Announcements From last time: Virtual Memory (Fotheringham, 1961)

ECE7995 Caching and Prefetching Techniques in Computer Systems. Lecture 8: Buffer Cache in Main Memory (I)

CSE 120 Principles of Operating Systems Spring 2017

How to create a process? What does process look like?

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

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

Page Replacement Algorithms

CS370 Operating Systems

VIRTUAL MEMORY. Maninder Kaur. 1

Page 1. Goals for Today" TLB organization" CS162 Operating Systems and Systems Programming Lecture 11. Page Allocation and Replacement"

Page Replacement. (and other virtual memory policies) Kevin Webb Swarthmore College March 27, 2018

Lecture 14: Cache & Virtual Memory

Virtual Memory Management

Memory management, part 2: outline. Operating Systems, 2017, Danny Hendler and Amnon Meisels

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

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

Virtual Memory COMPSCI 386

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

Operating Systems, Fall

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

Caching and Demand-Paged Virtual Memory

EvicMng the best page #2: FIFO. #1: Belady s Algorithm. CS 537 Lecture 11 Page Replacement Policies 11/1/11. Michael SwiF

Past: Making physical memory pretty

Readings and References. Virtual Memory. Virtual Memory. Virtual Memory VPN. Reading. CSE Computer Systems December 5, 2001.

Where are we in the course?

CS 4410 Operating Systems. Page Replacement (2) Summer 2016 Cornell University

Paging Policies, Load control, Page Fault Handling, Case studies January WT 2008/09

Virtual Memory. Today.! Virtual memory! Page replacement algorithms! Modeling page replacement algorithms

Page replacement algorithms OS

Demand Paging. Valid-Invalid Bit. Steps in Handling a Page Fault. Page Fault. Transfer of a Paged Memory to Contiguous Disk Space

Move back and forth between memory and disk. Memory Hierarchy. Two Classes. Don t

Memory Management Ch. 3

Transcription:

EECS 482 Introduction to Operating Systems Fall 2017 Manos Kapritsos Slides by: Harsha V. Madhyastha

Recap: Paging Both address spaces and physical memory broken up into fixed size pages Address Space Physical Memory Page 1 Page 2 Page 3 Page N October 26, 2017 EECS 482 Lecture 14 2

Paging Virt. page # Phys. page # resident protected 0 105 1 0 1 15 0 0 2 283 1 1 3 invalid invalid if (virtual page is invalid or non-resident or protected) { trap to OS fault handler; retry } else { physical page # = pagetable[virtual page #].physpagenum } October 26, 2017 EECS 482 Lecture 14 3

Page Replacement Not all valid pages may fit in physical memory Some pages are swapped out to disk To read in a page from disk, some resident page must be swapped out to disk Which page to evict when you need a free page? Goal: minimize page faults October 26, 2017 EECS 482 Lecture 14 4

Replacement policies Random FIFO Replace page brought into memory longest time ago May replace pages that continue to be frequently used Optimal? Replace page that won t be used for the longest time in the future Minimizes misses, but requires knowledge of the future October 26, 2017 EECS 482 Lecture 14 5

Replacement policies LRU (least recently used) Approximates OPT by using past reference pattern» If page hasn t been used for a while, it probably won t be used for a long time in the future LRU is hard to implement exactly Can we simplify LRU by approximating it? October 26, 2017 EECS 482 Lecture 14 6

The referenced bit Most MMUs maintain a referenced bit for each resident page Set by MMU when page is read or written Can be cleared by OS How to use reference bit to identify old pages? Why maintain reference bit in hardware? October 26, 2017 EECS 482 Lecture 14 7

Clock replacement algorithm Arrange resident pages around a clock F A B Algorithm to select page for eviction: Consider page pointed to by clock hand If not referenced, page hasn t been accessed since last sweep à Evict If referenced, page has been referenced since last sweep» What to do? What if all pages have been referenced since last sweep? What about new pages? E D C October 26, 2017 EECS 482 Lecture 14 8

LRU Clock P3: 1 P3: 0 P2: 1 P4: 0 P2: 0 P9: 1 P1: 1 P5: 1 P1: 0 P5: 1 P8: 1 P6: 1 P8: 1 P6: 1 P7: 0 P7: 0 A nice feature of clock is that it only adds overhead when you need to evict a page October 26, 2017 EECS 482 Lecture 14 9

Administrivia Almost finished grading midterm exams Will send out emails soon My office hours cancelled this Monday due to travel Start working on Project 3!!! Covered most of the material you need to know to do the project October 26, 2017 EECS 482 Lecture 14 10

Page eviction Where to evict page to? When do you NOT need to write page to disk? Rely on hardware/mmu to maintain dirty bit in PTE Why not write to disk on every store? The page that is brought from disk must wait while some page is evicted How could you optimize eviction? DON T use these optimizations in Project 3! October 26, 2017 EECS 482 Lecture 14 11

Page table contents Written by OS, Read by MMU Written by OS/MMU Read by OS Physical page # if (virtual page is non-resident or protected) { } else { trap to OS fault handler retry access physical page # = pagetable[virtual page #].physpagenum pagetable[virtual page #].referenced = true if (access is write) { pagetable[virtual page #].dirty = true } Resident access physical memory Read/Write enabled Dirty Referenced } October 26, 2017 EECS 482 Lecture 14 12

Page table contents Physical page # Resident Read/Write enabled Dirty Referenced Why no valid bit in PTE? All invalid virtual pages are non-resident For valid non-resident pages, does PTE contain disk block? OS must maintain this, MMU simply traps to OS Can we make do without resident bit? Use protection bits October 26, 2017 EECS 482 Lecture 14 13

Page table contents Physical page # Read/Write enabled Dirty Referenced Can we make do without dirty bit? Use protection bits Won t this increase # of page faults? October 26, 2017 EECS 482 Lecture 14 14

Page table contents Physical page # Read/Write enabled Referenced Can we make do without referenced bit? Application too may want to control protection Not in project 3 October 26, 2017 EECS 482 Lecture 14 15

Page table contents Physical page # read_enabled write_enabled October 26, 2017 EECS 482 Lecture 14 16

Project 3 Process view: Every process has an address space starting from VM_ARENA_BASEADDR of size VM_ARENA_SIZE When a process starts, entire address space is invalid Process calls vm_map to make pages valid Pages becomes invalid when process ends Pager view: One process runs at a time Sets up page table that MMU uses for translation Handles vm_create, vm_map, and vm_fault October 26, 2017 EECS 482 Lecture 14 17

Project 3 Swap-backed pages: Global swap file shared by all processes Pager controls where in swap file page is stored Private to a process File-mapped pages: Process specifies (file, offset) Can be shared across processes October 26, 2017 EECS 482 Lecture 14 18

Project 3 Do the project incrementally Swap-backed pages only without fork Then add support for fork and file-backed pages one after the other Pro Tip: Start with state diagrams Separate for swap-backed, file-backed pages October 26, 2017 EECS 482 Lecture 14 19

Project 3: State Diagram For each unique state, consider: Transitions? Read, write, clock, copy,... Attributes? Valid, resident, dirty,... Protections? Enable read, enable write? Mapped Valid: Yes Resident: Yes Dirty: No Zero-filled: Yes... Write Written Valid: Yes Resident: Yes Dirty: Yes Zero-filled: No... October 26, 2017 EECS 482 Lecture 14 20