Background. Demand Paging. valid-invalid bit. Tevfik Koşar. CSC Operating Systems Spring 2007

Similar documents
Module 9: Virtual Memory

Module 9: Virtual Memory

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

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

Chapter 10: Virtual Memory. Background

Chapter 10: Virtual Memory. Background. Demand Paging. Valid-Invalid Bit. Virtual Memory That is Larger Than Physical Memory

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

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

Page Replacement. 3/9/07 CSE 30341: Operating Systems Principles

Chapter 9: Virtual Memory

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - XIV Virtual Memory - I. Louisiana State University.

Chapter 9: Virtual Memory. Chapter 9: Virtual Memory. Objectives. Background. Virtual-address address Space

Where are we in the course?

Chapter 9: Virtual Memory

Chapter 9: Virtual-Memory

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

Chapter 9: Virtual-Memory Management. Operating System Concepts 8 th Edition,

Virtual Memory - I. Roadmap. Background. Demand Paging. valid-invalid bit. Tevfik Koşar. CSE 421/521 - Operating Systems Fall 2012

Background. Virtual Memory (2/2) Demand Paging Example. First-In-First-Out (FIFO) Algorithm. Page Replacement Algorithms. Performance of Demand Paging

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory

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

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

Chapter 3: Virtual Memory ว ตถ ประสงค. Background สามารถอธ บายข อด ในการท ระบบใช ว ธ การจ ดการหน วยความจ าแบบเสม อนได

Basic Page Replacement

Chapter 9: Virtual Memory

Chapter 8: Virtual Memory. Operating System Concepts

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory

Optimal Algorithm. Replace page that will not be used for longest period of time Used for measuring how well your algorithm performs

Operating System Concepts

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

Principles of Operating Systems

Page Replacement Algorithms

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory. Demand Paging

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

CS370 Operating Systems

Lecture 17. Edited from slides for Operating System Concepts by Silberschatz, Galvin, Gagne

CS420: Operating Systems

CS307: Operating Systems

Chapter 6: Demand Paging

Chapters 9 & 10: Memory Management and Virtual Memory

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

Chapter 10: Virtual Memory

Virtual Memory Outline

CS370 Operating Systems

Operating System Concepts 9 th Edition

ADRIAN PERRIG & TORSTEN HOEFLER Networks and Operating Systems ( ) Chapter 6: Demand Paging

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

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

OPERATING SYSTEM. Chapter 9: Virtual Memory

CS370 Operating Systems

CS370 Operating Systems

First-In-First-Out (FIFO) Algorithm

instruction is 6 bytes, might span 2 pages 2 pages to handle from 2 pages to handle to Two major allocation schemes

Virtual Memory COMPSCI 386

Virtual Memory: Page Replacement. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

Swapping. Operating Systems I. Swapping. Motivation. Paging Implementation. Demand Paging. Active processes use more physical memory than system has

Chapter 9: Virtual Memory

현재이이미지를표시할수없습니다. Chapter 9: Virtual Memory

CSE325 Principles of Operating Systems. Virtual Memory. David P. Duggan. March 7, 2013

1. Background. 2. Demand Paging

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

Virtual Memory - Overview. Programmers View. Virtual Physical. Virtual Physical. Program has its own virtual memory space.

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

UNIT - IV. What is virtual memory?

Chapter 8: Main Memory. Operating System Concepts 8th Edition

Operating Systems. Overview Virtual memory part 2. Page replacement algorithms. Lecture 7 Memory management 3: Virtual memory

Basic Memory Management

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

Memory management, part 2: outline

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

VII. Memory Management

Virtual Memory III. Jo, Heeseung

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

Virtual Memory B: Objec5ves

Operating Systems Virtual Memory. Lecture 11 Michael O Boyle

Memory Management Outline. Operating Systems. Motivation. Paging Implementation. Accessing Invalid Pages. Performance of Demand Paging

Operating Systems. No. 9 ศร ณย อ นทโกส ม Sarun Intakosum

CS 3733 Operating Systems:

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

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time.

Page Replacement Chap 21, 22. Dongkun Shin, SKKU

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University

VIRTUAL MEMORY READING: CHAPTER 9

Operating System - Virtual Memory

Introduction to Virtual Memory Management

CSE 4/521 Introduction to Operating Systems. Lecture 15 Virtual Memory I (Background, Demand Paging) Summer 2018

e-pg Pathshala Subject: Computer Science Paper: Operating Systems Module 29: Allocation of Frames, Thrashing Module No: CS/OS/29 Quadrant 1 e-text

Page Replacement Chap 21, 22. Dongkun Shin, SKKU

Topics: Virtual Memory (SGG, Chapter 09) CS 3733 Operating Systems

Chapter 4 Memory Management

Virtual Memory Management

Lecture 14 Page Replacement Policies

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

CS370 Operating Systems

Memory Management Virtual Memory

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

Memory Management and Protection

Virtual Memory. ICS332 Operating Systems

Transcription:

CSC 0 - Operating Systems Spring 007 Lecture - XIII Virtual Memory Tevfik Koşar Background Virtual memory separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical address space can therefore be much larger than physical address space. Allows address spaces to be shared by several processes. Allows for more efficient process creation. Virtual memory can be implemented via: Demand paging Demand segmentation Louisiana State University March 0 th, 007 Demand Paging Transfer of a Paged Memory to Contiguous Disk Space Bring a page into memory only when it is needed Less I/O needed Less memory needed Faster response More users Page is needed reference to it invalid reference abort not-in-memory bring to memory Valid-Invalid Bit Page Table When Some Pages Are Not in Main Memory With each page table entry a valid invalid bit is associated ( in-memory and legal, 0 not-in-memory or invalid) Initially valid invalid bit is set to 0 on all entries Example of a page table snapshot: Frame # M valid-invalid bit 0 page table 0 0 During address translation, if valid invalid bit in page table entry is 0 page fault

Page Fault Steps in Handling a Page Fault If there is ever a reference to a page, first reference will trap to OS page fault OS looks at another table to decide: Invalid reference abort. Just not in memory. Get empty frame. Swap page into frame. Reset tables, validation bit =. Restart instruction: Least Recently Used block move auto increment/decrement location What happens if there is no free frame? Page replacement find some page in memory, but not really in use, swap it out Algorithms (FIFO, LRU..) performance want an algorithm which will result in minimum number of page faults Same page may be brought into memory several times Performance of Demand Paging Page Fault Rate 0 p.0 if p = 0 no page faults if p =, every reference is a fault Effective Access Time (EAT) EAT = ( p) x memory access + p x (page fault overhead + [swap page out] + swap page in + restart overhead) Demand Paging Example Copy-on-Write Memory access time = microsecond 0% of the time the page that is being replaced has been modified and therefore needs to be swapped out Swap Page Time = 0 msec = 0,000 microsec EAT = ( p) x + p x (0,000 + / x 0,000) = +,999 x p (in microsec) What if out of 000 memory accesses cause a page fault? What if we only want 0% performance degradation? Copy-on-Write (COW) allows both parent and child processes to initially share the same pages in memory If either process modifies a shared page, only then is the page copied COW allows more efficient process creation as only modified pages are copied Free pages are allocated from a pool of zeroed-out pages (zero-fill-on-demand pages)

Page Replacement Prevent over-allocation of memory by modifying pagefault service routine to include page replacement Use modify (dirty) bit to reduce overhead of page transfers only modified pages are written to disk Page replacement completes separation between logical memory and physical memory large virtual memory can be provided on a smaller physical memory Basic Page Replacement. Find the location of the desired page on disk. Find a free frame: - If there is a free frame, use it - If there is no free frame, use a page replacement algorithm to select a victim frame. Read the desired page into the (newly) free frame. Update the page and frame tables.. Restart the process Page Replacement Page Replacement Algorithms Want lowest page-fault rate Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string In all our examples, the reference string is,,,,,,,,,,, Graph of Page Faults Versus The Number of Frames First-In-First-Out (FIFO) Algorithm Reference string:,,,,,,,,,,, frames ( pages can be in memory at a time per process) 9 page faults frames FIFO Replacement Belady s Anomaly more frames more page faults 0 page faults

FIFO Illustrating Belady s Anomaly Optimal Algorithm Replace page that will not be used for longest period of time frames example,,,,,,,,,,, 6 page faults How do you know this? Used for measuring how well your algorithm performs Least Recently Used (LRU) Algorithm LRU Algorithm (Cont.) Reference string:,,,,,,,,,,, Needs hardware assistance Counter implementation Every page entry has a counter; every time page is referenced through this entry, copy the clock into the counter When a page needs to be changed, look at the counters to determine which are to change Stack implementation keep a stack of page numbers in a double link form: Page referenced: move it to the top requires 6 pointers to be changed No search for replacement Use Of A Stack to Record The Most Recent Page References LRU Approximation Algorithms Reference bit With each page associate a bit, initially = 0 When page is referenced bit set to Replace the one which is 0 (if one exists). We do not know the order, however. Additional Reference bits byte for each page: eg. 0000 Shift right at each time interval Second chance Need reference bit Clock replacement If page to be replaced (in clock order) has reference bit = then: set reference bit 0 leave page in memory replace next page (in clock order), subject to same rules

Second-Chance (clock) Page-Replacement Algorithm Counting Algorithms Keep a counter of the number of references that have been made to each page LFU Algorithm: replaces page with smallest count MFU Algorithm: based on the argument that the page with the smallest count was probably just brought in and has yet to be used Allocation of Frames Each process needs minimum number of pages Example: IBM 70 6 pages to handle SS MOVE instruction: instruction is 6 bytes, might span pages pages to handle from pages to handle to Two major allocation schemes fixed allocation priority allocation Fixed Allocation Equal allocation For example, if there are 00 frames and processes, give each process 0 frames. Proportional allocation Allocate according to the size of process si = size of process pi S = " si m = total number of frames si ai = allocation for pi =! m S m = 6 si = 0 s = 7 0 a = " 6! 7 7 a = " 6! 9 7 Priority Allocation Use a proportional allocation scheme using priorities rather than size If process P i generates a page fault, select for replacement one of its frames select for replacement a frame from a process with lower priority number Global vs. Local Allocation Global replacement process selects a replacement frame from the set of all frames; one process can take a frame from another Local replacement each process selects from only its own set of allocated frames

Thrashing Thrashing (Cont.) If a process does not have enough frames, the page-fault rate is very high. This leads to: Replacement of active pages which will be needed soon again Thrashing a process is busy swapping pages in and out Which will in turn cause: low CPU utilization operating system thinks that it needs to increase the degree of multiprogramming another process added to the system Locality In A Memory-Reference Pattern Working-Set Model Δ working-set window a fixed number of page references Example: 0,000 instruction WSS i (working set of Process P i ) = total number of pages referenced in the most recent Δ (varies in time) if Δ too small will not encompass entire locality if Δ too large will encompass several localities if Δ = will encompass entire program D = Σ WSS i total demand frames if D > m Thrashing Policy if D > m, then suspend one of the processes Working-set model Keeping Track of the Working Set Approximate with interval timer + a reference bit Example: Δ = 0,000 Timer interrupts after every 000 time units Keep in memory bits for each page Whenever a timer interrupts copy and sets the values of all reference bits to 0 If one of the bits in memory = page in working set Why is this not completely accurate? Improvement = 0 bits and interrupt every 000 time units

Page-Fault Frequency Scheme Establish acceptable page-fault rate If actual rate too low, process loses frame If actual rate too high, process gains frame Any Questions? Hmm.. 8 Reading Assignment Read chapter 9 from Silberschatz. Acknowledgements Operating Systems Concepts book and supplementary material by Silberschatz, Galvin and Gagne. 9 0