Frequently asked questions from the previous class survey

Similar documents
CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CS370 Operating Systems

CS370 Operating Systems

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

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

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

Chapter 9: Virtual Memory

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

Chapter 9: Virtual-Memory

CS370 Operating Systems

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

Frequently asked questions from the previous class survey

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

Frequently asked questions from the previous class survey

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

Chapter 8: Virtual Memory. Operating System Concepts

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

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

CS370: Operating Systems [Spring 2016] Dept. Of Computer Science, Colorado State University

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Basic Memory Management

Chapter 9: Virtual Memory

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

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

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

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

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

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University

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

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

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

Virtual Memory Management

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

Course: Operating Systems Instructor: M Umair. M Umair

Course Outline. Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

Operating System - Virtual Memory

VIRTUAL MEMORY READING: CHAPTER 9

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

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

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

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

CS370 Operating Systems

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Memory management, part 2: outline

Frequently asked questions from the previous class survey

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

Frequently asked questions from the previous class survey

Frequently asked questions from the previous class survey

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Operating System Concepts

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

Chapter 10: Virtual Memory

CS420: Operating Systems

Module 9: Virtual Memory

Virtual Memory CHAPTER CHAPTER OBJECTIVES. 8.1 Background

Operating System Concepts 9 th Edition

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

CS370: Operating Systems [Spring 2016] Dept. Of Computer Science, Colorado State University

Lecture 14 Page Replacement Policies

Principles of Operating Systems

Page Replacement Algorithms

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

Frequently asked questions from the previous class survey

CS307: Operating Systems

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

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

Frequently asked questions from the previous class survey

Virtual Memory Outline

Basic Page Replacement

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

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

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

1. Background. 2. Demand Paging

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

OPERATING SYSTEM. Chapter 9: Virtual Memory

CS 153 Design of Operating Systems Winter 2016

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

Chapters 9 & 10: Memory Management and Virtual Memory

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

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

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

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

Even in those cases where the entire program is needed, it may not all be needed at the same time (such is the case with overlays, for example).

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

Virtual Memory COMPSCI 386

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

Operating Systems. Operating Systems Sina Meraji U of T

Frequently asked questions from the previous class survey

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

CS370 Operating Systems

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

Chapter 9: Virtual Memory

Operating Systems Virtual Memory. Lecture 11 Michael O Boyle

Virtual Memory. ICS332 Operating Systems

Frequently asked questions from the previous class survey

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

Transcription:

CS : OPERATING SYSTEMS [VIRTUAL MEMORY] Shrideep Pallickara Computer Science Colorado State University L. Frequently asked questions from the previous class survey Contents of page table entries in multilevel page table? L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Topics covered in this lecture Demand Paging Performance of Demand Paging Page Replacement Belady s anomaly Stack algorithms L. DEMAND PAGING L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Demand Paging: Basic concepts When a process is to be swapped in, guess which pages will be utilized by process Before the process will be swapped out again Avoid reading unused pages Better physical memory utilization Reduced I/O n Lower swap times L. Distinguishing between pages in memory and those on disk Valid-Invalid bits Associated with entries in the page table Valid Page is both legal and in memory Invalid Page is not in logical address space of process OR Valid BUT currently on disk L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Distinguishing between pages in memory and those on disk A B C D E F G H Logical Memory v I v I I 9 v I I Page Table Physical Memory 8 9 A C F Backing Store A B C D E F G H L. Handling Valid-invalid entries in the page table If process never attempts to access an invalid page? No problems If process accesses page that is not memory resident? Page fault L.8 SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Handling page faults Locate page on backing store OPERATING SYSTEM load M Reference PAGE I TABLE Restart instruction Trap to the OS Reset page table Free Frame PHYSICAL MEMORY BACKING STORE Bring in missing page L.9 Pure demand paging Never bring a page into memory unless it is required Execute process with no pages in memory First instruction of process will fault for the page Page fault to load page into memory and execute L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Potential problems with pure demand paging Multiple page faults per instruction execution One fault for instruction Many faults for data Multiple page faults per instruction are rare Locality of reference L. Hardware requirements to support demand paging Page Table Secondary memory Section of disk known as swap space is used L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Restarting instructions after a page fault Page faults occur at memory reference Use PCB to save state of the interrupted process Restart process in exactly the same place Desired page is now in memory and accessible L. Restarting processes after a page fault has been serviced If fault occurred during an instruction fetch During restart, refetch the instruction If fault occurred while fetching operands Fetch and decode instruction Fetch the operand L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Worst case example Add operands A and B Place sum in C If we fault while storing C Service page fault Update page table Restart instruction n Decode, fetch operand and perform addition L. Problems when operations modify several different memory locations E.g. Move a block from one memory location to another {C} Either block straddles page-boundary {C} Page fault occurs Move might be partially done Uh-oh L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.8

Approaches to fault-proofing block transfers Compute and access both ends of the block If a page fault were to happen: it will at this point n Nothing has been partially modified After fault servicing, block transfer completes Use temporary registers Track overwritten values L. Can on-demand paging be applied anywhere without modifications? Paging is between CPU and physical memory Transparent to user process Non-demand paging can be applied to any system Not so for demand paging Fault processing of special instructions non-trivial L.8 SLIDES CREATED BY: SHRIDEEP PALLICKARA L.9

PERFORMANCE OF DEMAND PAGING L.9 Effective access times Without page faults, effective access times are equal to memory access times nanoseconds approximately With page faults Account for fault servicing with disk I/O L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Calculating the effective access times with demand paging p : probability of a page fault ma : memory access time Effective access time = (-p) x ma + p x page-fault-time L. Components of page-fault servicing Service interrupt Read in the page Restart process ~ μs Latency : ms ~ μs Seek : ms L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Effective access times Effective access time = (-p) x ma + p x page-fault-time = (-p) x ns + p x (8mS) = (-p) x + p x (8,,) = +,999,8 x p Effective access time directly proportional to page-fault rate L. If performance degradation is to be less than % > +,999,8 x p >,999,8 x p p <. Fewer than memory access out of 99,99 can page-fault L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

OTHER ISSUES IN DEMAND PAGING L. Allocation of physical memory to I/O and programs is a challenge Memory used for holding program pages I/O buffers also consume a big chunk of memory Solutions: Fixed percentage set aside for I/O buffers Processes and the I/O subsystem compete L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Demand paging and the limits of logical memory Without demand paging All pages of process must be in physical memory Logical memory limited to size of physical memory With demand paging All pages of process need not be in physical memory Size of logical address space is no longer constrained by physical memory L. Demand paging is the OS attempt to improve CPU utilization and system throughput Load pages into memory when they are referenced Increases degree of multiprogramming Example pages of physical memory processes each of which is pages in size n Each process only needs pages as of now Run processes with pages to spare L.8 SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Increasing the degree of multiprogramming can be tricky Essentially we are over-allocating physical memory Example Physical memory = pages processes each of which is of size pages n But are using pages each as of now What happens if each process needs all pages? n physical frames needed L.9 Coping with over-allocation of memory Terminate a user process But paging should be transparent to the user Swap out a process Reduces the degree of multiprogramming Page replacement L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

The two core problems in demand paging Frame allocation How many frames to allocate to a process Page replacement Select the frame(s) for replacement Caveat: Disk I/O is expensive so inefficient solutions can weigh things down L. PAGE REPLACEMENT L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Page replacement If no frame is free? Find one that is not currently being used n Use it L. Freeing a physical memory frame Write frame contents to swap space Change page table of process To reflect that page is no longer in memory Freed frame can now hold some other page L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Servicing a page fault Retrieve page from disk YES Free frame available? NO Select victim frame Done using a page replacement algorithm Use it Write victim frame to disk L. Page replacement is central to demand paging Locate page on backing store OPERATING SYSTEM load M Reference PAGE I TABLE Restart instruction Trap to the OS Reset page table Free Frame PHYSICAL MEMORY BACKING STORE Bring in missing page L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.8

Overheads for page replacement If no frames are free: page transfers needed Victim page out New page in No free frames? Doubles page-fault service time Increases effective access time L. Using the modify bit to reduce page replacement overheads Each page/frame has a modify bit Set by hardware when page is written into Indicates if page was modified n Since the last time it was read from disk During page replacement If victim page not modified, no need to write it to disk n Reduces I/O time by one-half L.8 SLIDES CREATED BY: SHRIDEEP PALLICKARA L.9

PAGE REPLACEMENT ALGORITHMS L.9 Page replacement algorithms: What are we looking for? Low page-fault rates How do we evaluate them? Run algorithm on a string of memory references n Reference string Compute number of page faults L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

The reference string: Snapshot memory references We track page numbers Not the entire address If we have a reference to a memory-resident page p Any references to p that follow will not page fault n Page is already in memory L. The reference string: Example Page size = bytes 9,,,,,,,,,, L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Factors involved in determining page faults Reference string of executing process Page replacement algorithm Number of physical memory frames available Intuitively: Page faults reduce as the number of page frames increase L. FIFO (FIRST IN FIRST OUT) PAGE REPLACEMENT ALGORITHM L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

FIFO page replacement algorithm: Out with the old; in with the new When a page must be replaced Replace the oldest one OS maintains list of all pages currently in memory Page at head of the list: Oldest one Page at the tail: Recent arrival During a page fault Page at the head is removed New page added to the tail L. FIFO example: memory frames Reference String Youngest Oldest No page fault L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

BELADY S ANOMALY L. Intuitively the greater the number of memory frames, the lower the faults Surprisingly this is not always the case In 99 Belady, Nelson and Shedler discovered counter example* in FIFO FIFO caused more faults with frames than This strange situation is now called Belady s anomaly An anomaly in space-time characteristics of certain programs running in a paging machine. Belady, Nelson and Shedler. Communications of the ACM. Vol. () pp 9-. 99. L.8 SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

Belady s anomaly: FIFO Same reference string, different frames Youngest Oldest Numbers in this color: No page fault 9 page faults with frames Youngest Oldest page faults with frames L.9 Belady s anomaly Led to a whole theory on paging algorithms and properties Stack algorithms L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

STACK ALGORITHMS L. The Model There is an array M Keeps track of the state of memory M has as many elements as pages of virtual memory Divided into two parts Top part: m entries {Pages currently in memory} Bottom part: n-m entries n Pages that were referenced BUT paged out L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

The model Reference String m entries Page fault n elements Tracking the state of the array M over time L. Properties of the model When a page is referenced Move to the top entry of M If the referenced page is already in M All pages above it moved down one position Pages below it are not moved Transition from within box to outside of it? Page eviction from main memory L. SLIDES CREATED BY: SHRIDEEP PALLICKARA L.

SLIDES CREATED BY: SHRIDEEP PALLICKARA L.8 L. The model L. Properties of the model M(m,r) The set of pages in the top part of M m page frames r memory references

A property that has some interesting implications M(m, r) subset of M(m+, r) Set of pages in the top part of M with m frames Also included in M with (m+) frames L. What the subset relationship means Execute a process with a set of memory frames If we increase memory size by one frame and re-execute At every point of execution all pages in the first execution are present in the second run Does not suffer from Belady s anomaly Stack algorithms L.8 SLIDES CREATED BY: SHRIDEEP PALLICKARA L.9

The contents of this slide-set are based on the following references Avi Silberschatz, Peter Galvin, Greg Gagne. Operating Systems Concepts, 9 th edition. John Wiley & Sons, Inc. ISBN-: 98-8. [Chapter 9] Andrew S Tanenbaum. Modern Operating Systems. th Edition,. Prentice Hall. ISBN: 9X/ 98-9. [Chapter ] L.9 SLIDES CREATED BY: SHRIDEEP PALLICKARA L.