Lecture 41 Syed Mansoor Sarwar

Slides:



Advertisements
Similar presentations
Virtual Memory (Chapter 4.3)
Advertisements

Module 10: Virtual Memory
Page Replacement Algorithms (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.
Allocation of Frames Each process needs minimum number of pages
Operating Systems Prof. Navneet Goyal Department of Computer Science & Information Systems BITS, Pilani.
Page 15/4/2015 CSE 30341: Operating Systems Principles Allocation of Frames  How should the OS distribute the frames among the various processes?  Each.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 38 Frame Allocation Read.
03/31/2004CSCI 315 Operating Systems Design1 Allocation of Frames & Thrashing (Virtual Memory)
Chapter 101 Cleaning Policy When should a modified page be written out to disk?  Demand cleaning write page out only when its frame has been selected.
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
Advanced Operating Systems - Spring 2009 Lecture 17 – March 23, 2009 Dan C. Marinescu Office: HEC 439 B. Office hours:
Module 10: Virtual Memory Background Demand Paging Performance of Demand Paging Page Replacement Page-Replacement Algorithms Allocation of Frames Thrashing.
1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.
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
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.
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.
CSS430 Virtual Memory Textbook Ch9
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
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.
Part 8: Virtual Memory. Silberschatz, Galvin and Gagne ©2005 Virtual vs. Physical Address Space Each process has its own virtual address space, which.
Second-Chance Algorithm Basically, it’s a FIFO algorithm When a page has been selected, we inspect its reference bit. If the value is 0, we proceed to.
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.
Operating Systems CMPSC 473 Virtual Memory Management (3) November – Lecture 20 Instructor: Bhuvan Urgaonkar.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Page Replacement Allocation of.
CSC 360, Instructor: Kui Wu Memory Management II: Virtual Memory.
9.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 9.5 Allocation of Frames Each process needs minimum number of pages Example: machine.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
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
Virtual Memory.
Chapter 9: Virtual Memory
OPERATING SYSTEM CONCEPTS AND PRACTISE
Chapter 9: Virtual Memory
Chapter 9: Virtual Memory
Chapter 9: Virtual Memory
Module 9: Virtual Memory
Chapter 9: Virtual Memory
Chapter 9: Virtual Memory
Thrashing If a process does not have “enough” pages, the page-fault rate is very high. This leads to: low CPU utilization operating system thinks that.
CSC 539: Operating Systems Structure and Design Spring 2006
Lecture 40 Syed Mansoor Sarwar
5: Virtual Memory Background Demand Paging
Chapter 9: Virtual Memory
Chapter 6 Virtual Memory
Chapter 9: Virtual Memory
Operating Systems CMPSC 473
Chapter 9: Virtual Memory
Chapter 9 Virtual Memory
Module 9: Virtual Memory
Chapter 9: Virtual Memory CSS503 Systems Programming
Virtual Memory.
Presentation transcript:

Lecture 41 Syed Mansoor Sarwar Operating Systems Lecture 41 Syed Mansoor Sarwar

© Copyright Virtual University of Pakistan Agenda for Today Review of the previous lecture Thrashing The Working Set Model Page Fault Frequency Model Other Considerations Prepaging Page size Program structure Examples 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Review of Lecture 40 Belady’s Anomaly Page Replacement Algorithms Least Frequently Used (LFU) Most Frequently Used (MFU) Page Buffering Algorithm Allocation of Frames Minimum Number of Frames Thrashing 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Allocation of Frames Each process needs a minimum number of frames so that its execution may be guaranteed on a given machine . Example: MOV X,Y Instruction is 6 bytes long (16-bit offsets) and might span 2 pages. 2 pages to handle from. 2 pages to handle to. 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Allocation of Frames 1 2 3 4 5 6 7 8 9 Instruction X Y 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Thrashing If a process does not have “enough” pages, the page-fault rate is very high. This leads to: Low CPU utilization Operating system thinks that it needs to increase the degree of multiprogramming. Another process added to the system—serious problem! 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Thrashing A process is thrashing if it is spending more time paging (i.e., swapping pages in and out) than executing Thrashing results in severe performance problems Low CPU utilization High disk utilization Low utilization of other I/O devices 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Thrashing 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Thrashing To stop thrashing, the degree of multiprogramming needs to be reduced Local page replacement prevents thrashing to spread among several processes However, a thrashing process consumes more resources 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Locality of Reference Why does paging work? Locality of Reference Model The set of pages a process accesses actively, is known as its locality Process migrates from one locality to another Localities may overlap 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Process Localities 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Working Set Model Working Set Window () A fixed number of page references, e.g., 10,000 references Working Set Size of Pi (WSSi) Total number of pages referenced in the most recent  29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Working Set Model Let  = 10 references 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Process Localities         The first two and last localities are: L1 = {18-26, 31-34} L2 = {18-23, 29-31, 34} Last = { 18-20, 24-34} 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Working Set Model If  is too small, it will not encompass an entire locality If  is too large it will encompass several localities If  =   will encompass entire program 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Working Set Model If D is the total demand of frames in the system, then D =  WSSi If m is the total number of frames in the system, then D > m  Thrashing Policy: if D > m, then suspend one of the processes 29 April 2019 © Copyright Virtual University of Pakistan

Keeping Track of the Working Set Approximate with a fixed interval timer and a reference bit Example:  = 10,000 references Timer interrupts every 5000 references Keep in memory 2 bits for each page Whenever a timer interrupts, copy all reference bits and set their values to 0 After  references, if one of the bits in memory = 1  page in the working set 29 April 2019 © Copyright Virtual University of Pakistan

Keeping Track of the Working Set Why is this not completely accurate? Improvement: Use 10 reference bits and interrupt every 1000 references 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Page-Fault Frequency Another method to control thrashing. OS keeps track of the upper and lower bounds on the page-fault rates of processes If page-fault rate falls below the lower limit, the processes loses frames. If page-fault rate goes above the upper limit, process gains frames. 29 April 2019 © Copyright Virtual University of Pakistan

Page-Fault Frequency Scheme 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Other Considerations Prepaging Page size selection Internal fragmentation Page table size Locality I/O overhead Reduced with small page size because locality improves 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Other Considerations Program structure int A[1024][1024]; Matrix is stored in row-major order Each row is stored in one page Program 1 for (j = 0; j < 1024; j++) for (i = 0; i < 1024; i++) A[i,j] = 0; 1024 x 1024 page faults 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Other Considerations Program structure int A[1024][1024]; Matrix is stored in row-major order Each row is stored in one page Program 2 for (i = 0; i < 1024; i++) for (j = 0; j < 0124; j++) A[i,j] = 0; 1024 page faults 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Example System A demand paging system with the following utilizations: CPU = 20% Paging disk = 97.7% Other I/O devices = 5% Which of the following will improve CPU utilization? Install a faster CPU Increase degree of multiprogramming Decrease degree of multiprogramming Install more main memory 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Example Which of the following programming techniques and structures are “good” for a demand paged environment? Which are bad? Explain your answer. Stack Hash table Sequential search Binary search Indirection Vector operations 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Recap of Lecture Thrashing The Working Set Model Page Fault Frequency Model Other Considerations Prepaging Page size Program structure Examples 29 April 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Operating Systems Lecture 41 Syed Mansoor Sarwar 29 April 2019 © Copyright Virtual University of Pakistan