Virtual Memory. Background. No. 10. Virtual Memory: concept. Logical Memory Space (review) Demand Paging(1) Virtual Memory

Similar documents
If you miss a key. Chapter 6: Demand Paging Source:


#4 Inverted page table. The need for more bookkeeping. Inverted page table architecture. Today. Our Small Quiz

ELEC 377 Operating Systems. Week 6 Class 3

Nachos Project 3. Speaker: Sheng-Wei Cheng 2010/12/16

Cache Performance 3/28/17. Agenda. Cache Abstraction and Metrics. Direct-Mapped Cache: Placement and Access

Assembler. Building a Modern Computer From First Principles.

4/11/17. Agenda. Princeton University Computer Science 217: Introduction to Programming Systems. Goals of this Lecture. Storage Management.

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

Chapter 9: Virtual Memory

Memory and I/O Organization

Chapter 9: Virtual-Memory

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

CMPS 10 Introduction to Computer Science Lecture Notes

Real-Time Guarantees. Traffic Characteristics. Flow Control

Assembler. Shimon Schocken. Spring Elements of Computing Systems 1 Assembler (Ch. 6) Compiler. abstract interface.

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

CE 221 Data Structures and Algorithms

Chapter 8: Virtual Memory. Operating System Concepts

Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted from Hennessy & Patterson / 2003 Elsevier

Compiler Design. Spring Register Allocation. Sample Exercises and Solutions. Prof. Pedro C. Diniz

An Efficient Garbage Collection for Flash Memory-Based Virtual Memory Systems

Agenda & Reading. Simple If. Decision-Making Statements. COMPSCI 280 S1C Applications Programming. Programming Fundamentals

kccvoip.com basic voip training NAT/PAT extract 2008

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

Harvard University CS 101 Fall 2005, Shimon Schocken. Assembler. Elements of Computing Systems 1 Assembler (Ch. 6)

5.1 The ISR: Overvieui. chapter

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

NUMERICAL SOLVING OPTIMAL CONTROL PROBLEMS BY THE METHOD OF VARIATIONS

VRT012 User s guide V0.1. Address: Žirmūnų g. 27, Vilnius LT-09105, Phone: (370-5) , Fax: (370-5) ,

Efficient Distributed File System (EDFS)

Quantifying Performance Models

SLAM Summer School 2006 Practical 2: SLAM using Monocular Vision

IP Camera Configuration Software Instruction Manual

Chapter 9: Virtual Memory

Principles of Operating Systems

Module 9: Virtual Memory

Programming in Fortran 90 : 2017/2018

Brave New World Pseudocode Reference

Today s Outline. Sorting: The Big Picture. Why Sort? Selection Sort: Idea. Insertion Sort: Idea. Sorting Chapter 7 in Weiss.

Sorting Review. Sorting. Comparison Sorting. CSE 680 Prof. Roger Crawfis. Assumptions

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

CS307: Operating Systems

Virtual Memory COMPSCI 386

Chapter 9: Virtual Memory

For instance, ; the five basic number-sets are increasingly more n A B & B A A = B (1)

MRKOMNO. kéï=~ë=çñw= pfabufp=ud. aáöáí~ä=o~çáçöê~éüó. nìáåâ=êéñéêéååé=öìáçé==== båöäáëü

Assignment # 2. Farrukh Jabeen Algorithms 510 Assignment #2 Due Date: June 15, 2009.

Module 9: Virtual Memory

CS 268: Lecture 8 Router Support for Congestion Control

An Optimal Algorithm for Prufer Codes *

Loop Transformations for Parallelism & Locality. Review. Scalar Expansion. Scalar Expansion: Motivation

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

Insertion Sort. Divide and Conquer Sorting. Divide and Conquer. Mergesort. Mergesort Example. Auxiliary Array

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

ETAtouch RESTful Webservices

Sorting. Sorted Original. index. index

Problem Set 3 Solutions

Concurrent Apriori Data Mining Algorithms

Internet Traffic Managers

High level vs Low Level. What is a Computer Program? What does gcc do for you? Program = Instructions + Data. Basic Computer Organization

Exercises (Part 4) Introduction to R UCLA/CCPR. John Fox, February 2005

OPERATING SYSTEM. Chapter 9: Virtual Memory

K-means and Hierarchical Clustering

Solving Planted Motif Problem on GPU

Chapter 10: Virtual Memory

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

Motivation. EE 457 Unit 4. Throughput vs. Latency. Performance Depends on View Point?! Computer System Performance. An individual user wants to:

Solution Brief: Creating a Secure Base in a Virtual World

Operating System Concepts 9 th Edition

Intro. Iterators. 1. Access

News. Recap: While Loop Example. Reading. Recap: Do Loop Example. Recap: For Loop Example

Design and Analysis of Algorithms

6.854 Advanced Algorithms Petar Maymounkov Problem Set 11 (November 23, 2005) With: Benjamin Rossman, Oren Weimann, and Pouya Kheradpour

Notes on Organizing Java Code: Packages, Visibility, and Scope

A Sub-Critical Deficit Round-Robin Scheduler

Cache Memories. Lecture 14 Cache Memories. Inserting an L1 Cache Between the CPU and Main Memory. General Org of a Cache Memory

Loop Permutation. Loop Transformations for Parallelism & Locality. Legality of Loop Interchange. Loop Interchange (cont)

Chapter 6: Demand Paging

Simulation Based Analysis of FAST TCP using OMNET++

Overview. CSC 2400: Computer Systems. Pointers in C. Pointers - Variables that hold memory addresses - Using pointers to do call-by-reference in C

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

Computer Architecture ELEC3441

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

Operating System - Virtual Memory

Computer models of motion: Iterative calculations

Wightman. Mobility. Quick Reference Guide THIS SPACE INTENTIONALLY LEFT BLANK

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

The stream cipher MICKEY-128 (version 1) Algorithm specification issue 1.0

Midterms Save the Dates!

Chapter 9: Virtual Memory

AADL : about scheduling analysis

LOOP ANALYSIS. The second systematic technique to determine all currents and voltages in a circuit

Sorting: The Big Picture. The steps of QuickSort. QuickSort Example. QuickSort Example. QuickSort Example. Recursive Quicksort

Priority-Based Scheduling Algorithm for Downlink Traffics in IEEE Networks

CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar

Storage Binding in RTL synthesis

The Codesign Challenge

CSCI 104 Sorting Algorithms. Mark Redekopp David Kempe

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

Transcription:

Background EECS. Operatng System Fundamentals No. Vrtual Memory Prof. Hu Jang Department of Electrcal Engneerng and Computer Scence, York Unversty Memory-management methods normally requres the entre process to be n memory before the process can execute. Better not to load the whole process n memory for executon: Programs often have code to handle unusual error condtons. Arrays, lsts, and tables are often allocated more memory than they actually need. Certan optons and features of a program may be used rarely. Even all codes are needed, they may not all be needed at the same tme. Our goal: partally load a process. No longer be constraned by the amount of physcal memory. Each process takes less memory CPU utlzaton and throughput up. Less I/O to load program run faster. Logcal Memory Space (revew) Vrtual Memory: concept Physcal Memory (8M) Logcal Memory (>G) Dsk (>G) Vrtual Memory Vrtual memory can be mplemented va: Demand pagng Demand segmentaton Hard snce segments have varable sze Demand Pagng() Demand pagng: A pagng system wth a lazy page swapper. A lazy swapper: never swap a page nto memory unless the page wll be used. In demand pagng: When a process s executed, The pager guess whch pages are needed. (optonal) The pager brngs only these necessary pages nto memory. (optonal) When referrng a page not n a memory, the pager brng t n as needed and possbly replace an old page when no more free space. Hardware support: to dstngush those pages n memory and those pages n dsk. Use vald-nvald bt.

An example: Demand Pagng Handle a page fault A B C D E F G H Logcal Memory v v 9 v 8 9 A C F D E F A B C pagetable Physcal memory Dsk Handle a Page Fault The nterrupt handler program to handle page fault n vrtual memory: Check an nternal table to see f the reference was a vald or nvald memory access. If nvald, termnate the process; If vald, ths page s on dsk. Need page t nto memory. Fnd a free frame from the free-frame lst. (f no free frame, need replace an old page) Schedule a dsk operaton to read the desred page nto the newly allocated frame. When the dsk read s complete, modfy the nternal table and page table to set the bt as vald to ndcate ths page s now n memory. Restart the nstructon that was nterrupted. The process can now access the page as though t had always been n memory Handle a Page Fault (more detals) Trap to the OS Save the user regsters and process status. Determne the nterrupt was a page fault. Determne the locaton of the page on the dsk. Fnd a free frame from the free-frame lst. If no free frame, page replacement. Issue a read from the dsk to the free frame: Wat n a queue for the dsk untl servced. Wat for the dsk seek and latency tme. Begn the transfer of the page to the free frame. Whle watng, allocate the CPU to other process. Interrupt from the dsk (I/O completed). Save the regsters and process state for other runnng process. Determne the nterrupt was from the dsk. Handle a Page Fault (more detals) (cont d) Pure Demand Pagng vs. Pre-pagng Correct the page table and other tables to show the desred page s now n memory. Wake up the orgnal watng process. Wat for the CPU to be allocated to ths process agan. Restore the user regsters and process state and new page table. Resume the nterrupted nstructon. Pure Demand Pagng: Never brng a page nto memory untl t s referred. Start executng a process wth no pages n memory OS set nstructon ponter to the frst nstructon Once run, t causes a page fault to load the frst page Faultng as necessary untl every page s n memory Pre-pagng: To prevent hgh page-fault rate at the begnnng. Try to brng more pages at once based on predcton.

Some Archtecture Concerns n demand pagng Straghtforward n most cases: ADD A,B,C. Fetch and decode ADD. Fetch A. Fetch B. Add A and B. Store the sum to C But some nstructons whch may modfy somethng are not easy to handle: IBM /: MVC (move bytes) PDP-: auto-decrement or auto-ncrement addressng mode mov (R)++, --(R) Performance of Demand Pagng To servce a page fault s very tme-consumng: Servce the page-fault nterrupt. Read n the page. Restart the process. Effectve access tme for a demand-paged system: Effectve Access Tme = (-p) * ma + p * page fault tme One example: memory access nanosecond page fault mllsecond Effectve Access Tme = +,999,9 * p If p=/, EAT = mcrosecond ( slow down a factor of ) If requrng only % slow down, p</,, (one out of. mllon) How to acheve low page fault rate?? Handlng Swap Space on Dsk For fast speed: Use swap space, not fle system. Swap space: n larger blocks, no fle lookup and ndrect allocaton. Copyng an entre fle mage nto swap space at process startup and then perform demand pagng from the swap space. Or frst load pages from fle system, then wrte to swap space. Page Replacement() In demand pagng, when ncreasng multprogrammng level, t s possble to run out of all free frames. How about f a page fault occurs when no free frame s avalable? Stop the process. Swap out another process to free some frames. Page replacement: Replacng n page level. Page Replacement() If no frame s free, fnd one frame that s not currently beng used and free t. Wrte the page nto swap space and change pagetable to ndcate that ths page s no longer n memory. Use the freed frame to hold the page for whch the process faulted. Page Replacement Use a page-replacement algorthm to select a vctm frame. In ths case, two dsk accesses are requred (one wrte one read).

Page Replacement() Use a modfy bt (drty bt) to reduce overhead: Each frame has a modfy bt assocated n hardware. Any wrte n page wll set ths bt by hardware. In page replacement, f the bt s not set, no need to wrte back to dsk. For read-only pages, always no need to wrte back. Wth page replacement, we can run a large program n a small memory. Thrashng Thrashng: a process s spendng a sgnfcant tme n pagng. Thrashng results n severe performance problem. The process s spendng more tme n pagng than executng. Cause of thrashng: The process s not allocated enough frames to hold all the pages currently n actve use. Two mportant ssues: Page-replacement algorthm: how to select the frame to be replaced? Frame-allocaton algorthm: how many frames to allocate to each process? Localty Model of Programs A localty s a set of pages that are currently n an actve use by process. A process moves from localty to localty. A program s generally composed of several dfferent localtes. The localtes are defned by the program structure and ts data structures. Localty model s the basc prncple for cachng as well as demand pagng. We only need a small number of frames to hold all pages n the current localty n order to avod further page faults. Workng-set Model The model defne a workng-set wndow, say Δ page references, e.g.,, page references. The set of all referenced pages n the most recent Δ page references s the workng set. How to choose the wndow? f Δ too small wll not encompass entre localty. f Δ too large wll encompass several localtes. If Δ = wll encompass entre program. If WSS = workng-set sze of process P D = WSS : total demand frames f D > m (m: total avalable frames) Thrashng. Polcy: CPU montors workng sets of all processes and allocate enough frames for the current workng set. f D > m, then suspend one of the processes. Workng-Set Model Keepng Track of the Workng Set Approxmate wth nterval tmer + a reference bt. Example: Λ =, references Tmer nterrupts after every references. Keep n memory bts for each page. Whenever a tmer nterrupts, copy and sets the values of all reference bts to. If one of the bts n memory = page n workng set. The cost to servce these frequent nterrupts s hgh.

Page-Fault Frequency Other Consderatons n demand-pagng Establsh acceptable page-fault rate. If actual rate too low, process loses frame. If actual rate too hgh, process gans frame. Page sze: n powers of (** *) Small page sze large page-table. Small page sze less nternal fragmentaton. Small page sze more I/O overhead n pagng. Small page sze more page-faults. Small page sze less I/O amount (better resoluton) and less total allocated memory. A hstorcal trend s toward larger page szes. Other Consderatons n demand-pagng Program structure: a careful selecton of data structure and programmng structure To ncrease localty and hence lower the page-fault rate. To reduce total number of memory access. To reduce total number of pages touched. Also compler and loader can mprove. Example: Array A[][] of nteger Each row s stored n one page Program for j = to do for = to do A[][j] = ; x page faults Program for = to do for j = to do A[][j] = ; page faults