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

Similar documents
Frequently asked questions from the previous class survey

CS370 Operating Systems

CS370 Operating Systems

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

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

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

CS370 Operating Systems

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

Chapter 9: Virtual Memory

Chapter 9: Virtual-Memory

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

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

Chapter 8: Virtual Memory. Operating System Concepts

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

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

Basic Memory Management

Frequently asked questions from the previous class survey

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

Chapter 9: Virtual Memory

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

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

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

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

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

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

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

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

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

Course: Operating Systems Instructor: M Umair. M Umair

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

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

Virtual Memory Management

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

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

CS370 Operating Systems

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

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

VIRTUAL MEMORY READING: CHAPTER 9

Operating System Concepts

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

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

Operating System - Virtual Memory

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

Virtual Memory CHAPTER CHAPTER OBJECTIVES. 8.1 Background

Outlook. Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium

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

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

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

Frequently asked questions from the previous class survey

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

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

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

CS420: Operating Systems

Module 9: Virtual Memory

Chapter 10: Virtual Memory

CS307: Operating Systems

Memory management, part 2: outline

Operating System Concepts 9 th Edition

Principles of Operating Systems

1. Background. 2. Demand Paging

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

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

Frequently asked questions from the previous class survey

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

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

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

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

Frequently asked questions from the previous class survey

Page Replacement Algorithms

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

Basic Page Replacement

Frequently asked questions from the previous class survey

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

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

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

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).

Operating System 1 (ECS-501)

OPERATING SYSTEM. Chapter 9: Virtual Memory

Frequently asked questions from the previous class survey

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

Memory Management Ch. 3

Chapters 9 & 10: Memory Management and Virtual Memory

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

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

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

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

Virtual Memory COMPSCI 386

Virtual Memory. ICS332 Operating Systems

Frequently asked questions from the previous class survey

Virtual Memory Outline

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2

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

CS450/550 Operating Systems

Lecture 14 Page Replacement Policies

Frequently asked questions from the previous class survey

CS370 Operating Systems

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

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

Transcription:

Frequently asked questions from the previous class survey CS : OPERATNG SYSTEMS [VRTUAL MEMORY] Shrideep Pallickara Computer Science Colorado State University Multi-level paging: How many levels deep? Situations that are appropriate for hashed page tables and inverted page tables? Segments are always paged? Why not use use all -bits in a memory address? L. L. Frequently asked questions from the previous class survey Demand paging Backing store = swap space? Who determines which pages of a program are in memory? Does swapping pages happen during a context switch? Does it slow down individual programs? What if the RAM is full? Run on disk? Are frames mapped to pages when they are needed? Topics covered in this lecture Demand Paging Performance of Demand Paging Page Replacement L. 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 DEMAND PAGNG Avoid reading unused pages Better physical memory utilization Reduced /O n Lower swap times L.5 L. SLDES CREATED BY: SHRDEEP PALLCKARA L.

Distinguishing between pages in memory and those on disk Valid-nvalid bits Associated with entries in the page table Valid Page is both legal and in memory nvalid Page is not in logical address space of process OR Valid BUT currently on disk Distinguishing between pages in memory and those on disk L. CS: Operating 5 Systems [Spring ] 5 A B C D E F G H Logical Memory v 5 9 v v Page Table Physical Memory 5 8 9 A C F Backing Store A B C D E F G H L.8 Handling Valid-invalid entries in the page table Handling page faults f process never attempts to access an invalid page? No problems f process accesses page that is not memory resident? Page fault OPERATNG SYSTEM load M Reference PAGE TABLE Restart instruction Free 5 Frame Reset page table Locate page on backing store Trap to the OS PHYSCAL MEMORY L.9 Bring in missing page BACKNG STORE L. 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 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. L. SLDES CREATED BY: SHRDEEP PALLCKARA L.

Hardware requirements to support demand paging Page Table Secondary memory Section of disk known as swap space is used 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. L. Restarting processes after a page fault has been serviced f fault occurred during an instruction fetch During restart, refetch the instruction f fault occurred while fetching operands Fetch and decode instruction Fetch the operand Worst case example Add operands A and B Place sum in C f we fault while storing C Service page fault Update page table Restart instruction n Decode, fetch operand and perform addition L.5 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 Approaches to fault-proofing block transfers Compute and access both ends of the block f 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. L.8 SLDES CREATED BY: SHRDEEP PALLCKARA 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 PERFORMANCE OF DEMAND PAGNG L.9 L. 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 /O 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. L. Components of page-fault servicing Service interrupt Read in the page Restart process ~ µs Latency : ms ~ µs Seek : 5 ms 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. L. SLDES CREATED BY: SHRDEEP PALLCKARA L.

f performance degradation is to be less than % > +,999,8 x p >,999,8 x p p <.5 Fewer than memory access out of 99,99 can page-fault OTHER SSUES N DEMAND PAGNG L.5 L. Allocation of physical memory to /O and programs is a challenge Memory used for holding program pages /O buffers also consume a big chunk of memory Solutions: Fixed percentage set aside for /O buffers Processes and the /O subsystem compete 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. L.8 Demand paging is the OS attempt to improve CPU utilization and system throughput Load pages into memory when they are referenced ncreases degree of multiprogramming Example pages of physical memory processes each of which is pages in size n Each process only needs 5 pages as of now Run processes with pages to spare ncreasing 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 5 pages each as of now What happens if each process needs all pages? n physical frames needed L.9 L. SLDES CREATED BY: SHRDEEP PALLCKARA L.5

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 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 /O is expensive so inefficient solutions can weigh things down L. L. Page replacement f no frame is free? Find one that is not currently being used n Use it PAGE REPLACEMENT L. L. Freeing a physical memory frame Servicing a page fault 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 YES Retrieve page from disk Free frame available? NO Done using a page replacement algorithm Select victim frame Use it Write victim frame to disk L.5 L. SLDES CREATED BY: SHRDEEP PALLCKARA L.

Page replacement is central to demand paging Overheads for page replacement OPERATNG SYSTEM load M Reference PAGE TABLE Restart instruction 5 Reset page table Locate page on backing store Trap to the OS Free Frame PHYSCAL MEMORY Bring in missing page BACKNG STORE L. f no frames are free: page transfers needed Victim page out New page in No free frames? Doubles page-fault service time ncreases effective access time L.8 Using the modify bit to reduce page replacement overheads Each page/frame has a modify bit Set by hardware when page is written into ndicates if page was modified n Since the last time it was read from disk During page replacement f victim page not modified, no need to write it to disk n Reduces /O time by one-half PAGE REPLACEMENT ALGORTHMS L.9 L. 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 The reference string: Snapshot memory references We track page numbers Not the entire address f 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. L. SLDES CREATED BY: SHRDEEP PALLCKARA L.

The reference string: Example Page size = bytes 9 5 Factors involved in determining page faults Reference string of executing process Page replacement algorithm Number of physical memory frames available,,,,,,,,,, ntuitively: Page faults reduce as the number of page frames increase L. L. FFO 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 FFO (FRST N FRST OUT) PAGE REPLACEMENT ALGORTHM During a page fault Page at the head is removed New page added to the tail L.5 L. FFO example: memory frames Reference String Youngest Oldest No page fault BELADY S ANOMALY L. L.8 SLDES CREATED BY: SHRDEEP PALLCKARA L.8

ntuitively the greater the number of memory frames, the lower the faults Surprisingly this is not always the case n 99 Belady, Nelson and Shedler discovered counter example* in FFO FFO 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-5. 99. L.9 Belady s anomaly: FFO Same reference string, different frames Youngest Oldest Youngest Oldest Numbers in this color: No page fault 9 page faults with frames page faults with frames L.5 Belady s anomaly Led to a whole theory on paging algorithms and properties Stack algorithms 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, nc. SBN-: 98-8. [Chapter 9] Andrew S Tanenbaum. Modern Operating Systems. th Edition,. Prentice Hall. SBN: 59X/ 98-59. [Chapter ] L.5 L.5 SLDES CREATED BY: SHRDEEP PALLCKARA L.9