Operating Systems Prof. Navneet Goyal Department of Computer Science & Information Systems BITS, Pilani.

Slides:



Advertisements
Similar presentations
Module 10: Virtual Memory
Advertisements

Chapter 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 8 Virtual Memory
Allocation of Frames Each process needs minimum number of pages
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.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Segmentation and Paging Considerations
Virtual-Memory Management
Gordon College Stephen Brinton
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Virtual Memory.
Virtual Memory Chapter 8.
Virtual Memory Chapter 8.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
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.
Virtual Memory Chapter 8.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory.
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Revisiting Virtual Memory.
Virtual Memory I Chapter 8.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
A. Frank - P. Weisberg Operating Systems Virtual Memory Policies.
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.
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.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
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.
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.
9.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts Chapter 9: Virtual-Memory Management Background Demand Paging Page Replacement Allocation.
#include pthread_mutex_t sem_mut = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t cond_mut = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
9.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 9.5 Allocation of Frames Each process needs minimum number of pages Example: machine.
Lectures 8 & 9 Virtual Memory - Paging & Segmentation System Design.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
Chapter 9: Virtual Memory
Virtual Memory Chapter 8.
Chapter 8 Virtual Memory
Virtual Memory Chapter 8.
Module 9: Virtual Memory
Chapter 9: Virtual Memory
5: Virtual Memory Background Demand Paging
Chapter 6 Virtual Memory
Operating Systems CMPSC 473
Lecture 41 Syed Mansoor Sarwar
Module 9: Virtual Memory
Virtual Memory.
Presentation transcript:

Operating Systems Prof. Navneet Goyal Department of Computer Science & Information Systems BITS, Pilani

Topics for Today Thrashing Working Set

Thrashing Swapping out a piece of a process just before that piece is needed The processor spends most of its time swapping pieces rather than executing user instructions

Principle of Locality Program and data references within a process tend to cluster Only a few pieces of a process will be needed over a short period of time Possible to make intelligent guesses about which pieces will be needed in the future This suggests that virtual memory may work efficiently

Locality In A Memory-Reference Pattern

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 Thrashing  a process is busy swapping pages in and out

Thrashing (Cont.)

Demand Paging and Thrashing Why does demand paging work? Locality model ▫Process migrates from one locality to another ▫Localities may overlap Why does thrashing occur?  size of locality > total memory size

Working-Set Model   working-set window  a fixed number of page references Example: 10,000 instruction WSS i (working set size of Process P i ) = total number of pages referenced in the most recent  (varies in time) ▫if  too small will not encompass entire locality ▫if  too large will encompass several localities ▫if  =   will encompass entire program D =  WSS i  total demand frames if D > m  Thrashing Policy if D > m, then suspend one of the processes

Working-set model

Keeping Track of the Working Set Approximate with interval timer + a reference bit Example:  = 10,000 ▫Timer interrupts after every 5000 time units ▫Keep in memory 2 bits for each page ▫Whenever a timer interrupts copy and sets the values of all reference bits to 0 ▫If one of the bits in memory = 1  page in working set Why is this not completely accurate? Improvement = 10 bits and interrupt every 1000 time units

Page Size Smaller page size, less amount of internal fragmentation Smaller page size, more pages required per process More pages per process means larger page tables Larger page tables means large portion of page tables in virtual memory Secondary memory is designed to efficiently transfer large blocks of data so a large page size is better

Page Size Small page size, large number of pages will be found in main memory As time goes on during execution, the pages in memory will all contain portions of the process near recent references. Page faults low. Increased page size causes pages to contain locations further from any recent reference. Page faults rise.

Frame Allocation: Issues Smaller no. of frames to a process – more processes can reside in MM – increases probability that OS will find at least one ready process Despite Principle of Locality, Page faults rate will be high Beyond a certain size, additional allocation will have no noticeable effect on page fault rate because of Principle of Locality

Frame Allocation Schemes Fixed Allocation –Equal Allocation –Proportional Allocation Priority Allocation

Fixed Allocation Equal allocation – e.g., if 100 frames and 5 processes, give each 20 pages. Proportional allocation – Allocate according to the size of process.

Priority Allocation Use a proportional allocation scheme using priorities rather than size. If process P i generates a page fault, –select for replacement one of its frames. –select for replacement a frame from a process with lower priority number.

Global vs. Local Allocation Global replacement – process selects a replacement frame from the set of all frames; one process can take a frame from another. Local replacement – each process selects from only its own set of allocated frames.