1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

Slides:



Advertisements
Similar presentations
Memory.
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
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.
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.
Segmentation and Paging Considerations
Virtual-Memory Management
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 17: Wrapping up Virtual Memory.
Gordon College Stephen Brinton
Memory Management Design & Implementation Segmentation Chapter 4.
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
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
ECE668.1 Csaba Andras Moritz UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Computer Architecture ECE 668 Review of MMU and Virtual.
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.
Page 110/20/2015 CSE 30341: Operating Systems Principles So far…  Page  Fixed size pages solve page allocation problem (and external fragmentation) 
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Background Virtual memory –
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.
1 Memory Management (b). 2 Paging  Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter.
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;
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 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Chapter 9: Virtual Memory. Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Main Memory: Paging and Segmentation CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
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
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
5: Virtual Memory Background Demand Paging
Main Memory Background Swapping Contiguous Allocation Paging
Lecture 3: Main Memory.
Chapter 6 Virtual Memory
Operating Systems CMPSC 473
Lecture 41 Syed Mansoor Sarwar
Module 9: Virtual Memory
Virtual Memory.
Presentation transcript:

1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier

2 Example §Pt = Probability of TLB miss = 0.1 §Pf =Probability of page fault when TLB miss occurs = §Tt = time to access TLB = 0.1 µsec §Tm = time to access memory = 1 µsec §Td = time to transfer page to or from disk=10ms §Pd = Probability that page is dirty when replaced =0.5 What is the effective access time for a memory reference?

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

4 Global vs. Local Allocation §Global replacement l Process cannot control its own fault rate l Set of pages allocated depends on paging behavior of other processes l Slow down due to external circumstances l More commonly used technique §Local replacement l Cannot make use of less used pages of other processes

5 §We must have enough frames to hold all the different pages that a single instruction can reference. §Defined by instruction set architecture §Allocating only the minimum results in very high paging activity

6 §Thrashing occurs when a process is spending more time paging than executing.

7 Thrashing §If a process does not have “enough” pages, the page-fault rate is very high. This leads to: l low CPU utilization. l operating system thinks that it needs to increase the degree of multiprogramming. l another process added to the system. §Thrashing  a process is busy swapping pages in and out.

8 Thrashing §Queue of paging device remains a problem in local replacement algorithm

9 Thrashing

10 Why does paging work? Locality model Process migrates from one locality to another. Localities may overlap. Why does thrashing occur?  size of locality > total memory size

11 Working-Set Model §   working-set window §most recent page references §WSS i (working set of Process P i ) = total number of pages referenced in the most recent  (varies in time) l if  too small will not encompass entire locality. l if  too large will encompass several localities. l if  =   will encompass entire program.

12 Working-Set Model §D =  WSS i  total demand frames §if D > m  Thrashing §Policy if D > m, then suspend one of the processes.

13 Working-set model

14 Keeping Track of the Working Set §Approximate with interval timer + a reference bit §Example:  = 10,000 l Timer interrupts after every 5000 time units. l Keep in memory 2 bits for each page. l Whenever a timer interrupts copy and sets the values of all reference bits to 0. l If one of the bits in memory = 1  page in working set.

15 Keeping Track of the Working Set §Improvement = 10 bits and interrupt every 1000 time units.

16 Page-Fault Frequency Scheme §Establish “acceptable” page-fault rate. l If actual rate too low, process loses frame. l If actual rate too high, process gains frame.

17 1.CPU utilization = 13%, Paging Disk Utilization = 97% 2.CPU utilization = 87%, Paging Disk Utilization = 3% 3.CPU utilization = 13%, Paging Disk Utilization = 3%

18 What will improve the CPU utilization? §CPU utilization 20% §Paging disk97.7% §Other I/O devices 5% 1.Install a bigger paging disk? 2.Increase degree of multiprogramming? 3.Decrease degree of multiprogramming? 4.Install more memory? 5.Install faster hard disk? 6.Increase page size?

19 Other Considerations Program structure §Demand paging is designed to be transparent to user §Sometimes system performance can be improved if user (or compiler) is aware of underlying demand paging §Careful selection of data structures increases locality and hence lower page fault rate and number of pages in the working set.

20 Other Considerations Program structure §Stack has good locality §Hash table produces bad locality by scattering references §However, locality of reference is just one measure of efficiency of use of data structure. Other heavily weighted factors include total number of memory references and total number of pages touched.

21 Other Considerations Program structure §Compiler and loader can have significant effect on paging. §Loader can avoid placing routine across page boundaries, keeping each routine in a page §Routines that call each other can be packed into same page.

22 §Program structure (Assume: Less than 1024 pages are allocated the process). l A = 1024 x 1024 integer array l Each row is stored in one page l Program 1 for (j = 0; j < A.length; j++) for (i = 0; i < A.length; i++) A[i,j] = 0; l Program 2 for (i = 0; i < A.length; i++) for (j = 0; j < A.length; j++) A[i,j] = 0;

23 §Program structure (Assume: Less than 1024 pages are allocated the process). l A = 1024 x 1024 array l Each row is stored in one page l Program 1 for (j = 0; j < A.length; j++) for (i = 0; i < A.length; i++) A[i,j] = 0; 1024 x 1024 page faults Program 2 for (i = 0; i < A.length; i++) for (j = 0; j < A.length; j++) A[i,j] = 0; 1024 page faults

24 §Program structure l A = 100 x 100 array for (j = 0; j < 100; j++) for (i = 0; i < 100; i++) A[i,j] = 0; l Array is stored row major l Page size is 400 bytes l 4 frames are allocated to the process. l One array element takes 1 byte of space l Use LRU page replacement What are the number of page faults?

25 Other Considerations I/O interlock §Lock bit associated with each frame §Another use: decide to prevent replacing a newly brought in page until it is used at least once.

26 §Swap space

27 User’s View of a Program

28 Logical View of Segmentation user spacephysical memory space

29 Segmentation Architecture §Logical address consists of a two tuple:, §Segment table – maps two-dimensional physical addresses; each table entry has: l base – contains the starting physical address where the segments reside in memory. l limit – specifies the length of the segment. §Segment-table base register (STBR) points to the segment table’s location in memory. §Segment-table length register (STLR) indicates number of segments used by a program; segment number s is legal if s < STLR.

30 Segmentation Hardware

31 Example of Segmentation

32 §Given a system that uses segmentation, for the following process, give the physical address for the following logical addresses § SegmentBaseLength

33 Protection and Sharing of Segments

34 §Fragmentation §Caching issues similar to paging

35 §Process in one segment §Fixed segments §Variable segments

36 §Combined schemes