CSC 360, Instructor: Kui Wu Memory Management II: Virtual Memory.

Slides:



Advertisements
Similar presentations
Module 10: Virtual Memory
Advertisements

Chapter 10: Virtual Memory
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Chapter 9: Virtual Memory
國立台灣大學 資訊工程學系 Chapter 9: Virtual Memory. 資工系網媒所 NEWS 實驗室 Objectives To describe the benefits of a virtual memory system To explain the concepts of demand.
Virtual Memory Operating System Concepts chapter 9 CS 355
03/31/2004CSCI 315 Operating Systems Design1 Allocation of Frames & Thrashing (Virtual Memory)
9.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory OSC: Chapter 9. Demand Paging Copy-on-Write Page Replacement.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 15: Background Information for the VMWare ESX Memory Management.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Module 9: Virtual Memory
Module 10: Virtual Memory Background Demand Paging Performance of Demand Paging Page Replacement Page-Replacement Algorithms Allocation of Frames Thrashing.
Chapter 9: Virtual-Memory Management. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 9: Virtual Memory Background Demand Paging.
Virtual Memory Background Demand Paging Performance of Demand Paging
Virtual Memory Introduction to Operating Systems: Module 9.
Virtual-Memory Management
Gordon College Stephen Brinton
Virtual Memory CS 3100 Virutal Memory.
Chapter 9: Virtual Memory
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Virtual Memory.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 9: Virtual Memory Background.
Chapter 10: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 10: Virtual Memory.
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Revisiting Virtual Memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 9: Virtual Memory Background.
03/29/2004CSCI 315 Operating Systems Design1 Page Replacement Algorithms (Virtual Memory)
Chapter 9: Virtual Memory. Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Page 19/17/2015 CSE 30341: Operating Systems Principles Optimal Algorithm  Replace page that will not be used for longest period of time  Used for measuring.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
Chapter 9: Virtual-Memory Management. 9.2Operating System Principles Chapter 9: Virtual-Memory Management Background Demand Paging Copy-on-Write Page.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Background Virtual memory –
Operating System Concepts 7th Edition Abraham SilBerschatz Peter Baer Galvin Greg Gagne Prerequisite: CSE212.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 9: Virtual Memory Background.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 9: Virtual Memory Background.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples Operating.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Page Replacement Allocation of.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Outline n Background n Demand.
Chapter 9: Virtual Memory. 9.2 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
CS307 Operating Systems Virtual Memory Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
9.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 9: Virtual Memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
Chapter 9: Virtual-Memory Management. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 9: Virtual-Memory Management 9.1 Background.
9.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 9: Virtual Memory.
1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples (not covered.
10.1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
Chapter 9: Virtual Memory. Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
Chapter 9: Virtual Memory. Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 9: Virtual Memory.
Chapter 9: Virtual Memory
OPERATING SYSTEM CONCEPTS AND PRACTISE
Chapter 9: Virtual Memory
Module 9: Virtual Memory
Chapter 9: Virtual Memory
Chapter 9: Virtual-Memory Management
Lecture 40 Syed Mansoor Sarwar
5: Virtual Memory Background Demand Paging
Chapter 9: Virtual Memory
Chapter 6 Virtual Memory
Operating Systems CMPSC 473
Module 9: Virtual Memory
Presentation transcript:

CSC 360, Instructor: Kui Wu Memory Management II: Virtual Memory

CSC 360, Instructor: Kui Wu Agenda 1.Background 2.Demand Paging 3.Copy-on-Write 4.Page Replacement 5.Allocation of Frames 6.Thrashing 7.Memory-Mapped Files

CSC 360, Instructor: Kui Wu CSc Background (1): Virtual memory Load an entire process in physical memory? not all addresses accessed at the same time some even not used before swapped out! Virtual memory logical space >> physical space –only load the portion being used or to be used more (partial) processes in physical memory faster swap in/out

CSC 360, Instructor: Kui Wu CSc Background (2): Virtual vs physical memory

CSC 360, Instructor: Kui Wu CSc Demand paging (1) On demand when used –being referenced –really invalid reference? ·error! –valid but not-in-memory ·page in lazy pager valid-invalid bit Q: Demand segmenting?

CSC 360, Instructor: Kui Wu CSc Demand paging (2): Page fault Reference Trap to OS Page in Update Restart issues Q: block move instruction

CSC 360, Instructor: Kui Wu CSc Demand paging (3): performance Page Fault Rate 0 <= p <= 1.0 if p = 0, no page faults if p = 1, every reference is a fault Effective Access Time (EAT) EAT = (1 – p) x memory access + p (page fault overhead + swap page out + swap page in + restart overhead) Example

CSC 360, Instructor: Kui Wu CSc Copy-on-write Share read-only pages page C’

CSC 360, Instructor: Kui Wu CSc Page Replacement (1): The need

CSC 360, Instructor: Kui Wu CSc Page Replacement (2): Basic page replacement Page in no free frame? –choose a victim –swap out ·dirty bit Algorithms allocation replacement Reduce fault rate Q: modify bit

CSC 360, Instructor: Kui Wu CSc Page Replacement (3): First-in- first-out (FIFO) Reference string 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 3 frames 4 frames Belady’s Anomaly more frames: more page faults! page faults page faults 4 43

CSC 360, Instructor: Kui Wu CSc Page Replacement (4): Optimal algorithm Replace the page will not be used for the longest period of time how do you know the future?! –if history is of any indication … page faults 4 5 Q: how to achieve optimality?

CSC 360, Instructor: Kui Wu CSc Page Replacement (5): Least recently used (LRU) Replace the least recently used Counter implementation copy timestamp search to replace Stack implementation move to top replace the bottom

CSC 360, Instructor: Kui Wu CSc Page Replacement (6): LRU approximation algorithms Additional-reference-bits algorithm set reference bit on reference shift into a history byte on timer least-recently-used one has lowest history byte Second-chance algorithm if 0, replace if 1, change to 0 and check the next page circular queue

CSC 360, Instructor: Kui Wu CSc Page Replacement (7): Counting-based algorithms Counter number of references Least frequently used (LFU) replace the one with the smallest counter aging necessary Most frequently used (MFU) new page has small counter –and might be referenced soon

CSC 360, Instructor: Kui Wu CSc Page Replacement (8): Page buffering Keep a pool of free pages speed up swapping in desired pages no need to wait a page becomes free Keep a list of modified pages synch with disk when paging is idle reduce overhead when swapping out Reuse “clean” pages from the pool on page fault, check free pool first

CSC 360, Instructor: Kui Wu CSc Page allocation (1) A process needs minimum number of pages e.g., IBM 370: 6 pages to handle SS MOVE –instruction is 6 bytes, might span 2 pages –2 pages to handle from –2 pages to handle to Two major allocation schemes fixed allocation priority allocation

CSC 360, Instructor: Kui Wu CSc Page allocation (2): Fixed allocation Equal allocation M free pages N requesting processes allocation: floor(M/N) each –some processes may request less than M/N Proportional allocation each process requests s i ; all request S=sum s i allocation: s i /S*M

CSC 360, Instructor: Kui Wu CSc Page allocation (3): Priority allocation Allocation proportional to priority higher priority process gets more pages allocated when necessary On page fault select for replacement one of its frames. select for replacement a frame from a process with lower priority number Global vs local replacement

CSC 360, Instructor: Kui Wu CSc Thrashing (1) Thrashing more time on paging than executing –busy I/O, idle CPU –more processes admitted, more page faults –more processes in thrashing! Why thrashing paging: explore locality thrashing: locality explored too much!

CSC 360, Instructor: Kui Wu CSc Thrashing (2): Paging and thrashing Why does thrashing occur? sum of size of locality > total memory size

CSC 360, Instructor: Kui Wu CSc Thrashing (3): Working-set model Prevent thrashing local replacement sufficient provisioning working-set model –working-set window ·most recent page references –working-set size (WSS) ·number of unique page references when sum WSS i >M, reduce multiprogramming!

CSC 360, Instructor: Kui Wu CSc Memory-mapped files (1): Memory sharing

CSC 360, Instructor: Kui Wu CSc Memory-mapped files (2) Memory-mapped file I/O allows file I/O to be treated as routine memory access by mapping a disk block to a page in memory A file is initially read using demand paging. A page-sized portion of the file is read from the file system into a physical page. Subsequent reads/writes to/from the file are treated as ordinary memory accesses. Simplifies file access by treating file I/O through memory rather than read() write() system calls Also allows several processes to map the same file allowing the pages in memory to be shared

CSC 360, Instructor: Kui Wu CSc Memory-mapped files(3): Memory-mapped file sharing