03/26/2010CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying an earlier.

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 9 Virtual Memory Bernard Chen 2007 Spring.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 36 Virtual Memory Read.
Virtual Memory Management G. Anuradha Ref:- Galvin.
9.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 9: 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  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.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
03/22/2004CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
03/17/2008CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
03/29/2004CSCI 315 Operating Systems Design1 Page Replacement Algorithms (Virtual Memory)
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
Part 8: Virtual Memory. Silberschatz, Galvin and Gagne ©2005 Virtual vs. Physical Address Space Each process has its own virtual address space, which.
Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
CS212: OPERATING SYSTEM Lecture 6: Virtual-Memory Management 1 Computer Science Department.
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 Operating System Concepts Chapter 9: 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.
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.
Virtual Memory. Background Virtual memory is a technique that allows execution of processes that may not be completely in the physical memory. Virtual.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
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.
1 Virtual Memory. Cache memory: provides illusion of very high speed Virtual memory: provides illusion of very large size Main memory: reasonable cost,
Lecture 19 Virtual Memory Demand Paging. Background Virtual memory – separation of user logical memory from physical memory. –Only part of the program.
Virtual Memory The address used by a programmer will be called a virtual address or logical address. An address in main memory is called a physical address.
Chapter 9: Virtual-Memory Management. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 9: Virtual-Memory Management 9.1 Background.
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 ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual-Memory Management.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
Virtual Memory CSSE 332 Operating Systems
Chapter 9: Virtual Memory – Part I
Chapter 9: Virtual Memory
Chapter 9: Virtual Memory
Module 9: Virtual Memory
Chapter 9: Virtual Memory
Chapter 9: Virtual-Memory Management
Operating Systems Lecture November 2018.
What Happens if There is no Free Frame?
5: Virtual Memory Background Demand Paging
Chapter 9: Virtual Memory
Chapter 6 Virtual Memory
Operating Systems CMPSC 473
Module 9: Virtual Memory
Virtual Memory.
Chapter 8 & 9 Main Memory and Virtual Memory
Presentation transcript:

03/26/2010CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying an earlier edition of the course text Operating Systems Concepts with Java, by Silberschatz, Galvin, and Gagne. Many, if not all, of the illustrations contained in this presentation come from this source.

03/26/2010CSCI 315 Operating Systems Design2 Virtual Memory Virtual memory – separation of user logical memory from physical memory. –Only part of the program needs to be in memory for execution. –Logical address space can therefore be much larger than physical address space. –Allows address spaces to be shared by several processes. –Allows for more efficient process creation. Virtual memory can be implemented via: –Demand paging –Demand segmentation

03/26/2010CSCI 315 Operating Systems Design3 Virtual Memory Larger than Physical Memory

03/26/2010CSCI 315 Operating Systems Design4 Demand Paging Bring a page into memory only when it is needed. –Less I/O needed. –Less memory needed. –Faster response. –More users. Page is needed (there is a reference to it): –invalid reference  abort. –not-in-memory  bring to memory.

03/26/2010CSCI 315 Operating Systems Design5 Transfer of a Paged Memory to Contiguous Disk Space

03/26/2010CSCI 315 Operating Systems Design6 Valid-Invalid Bit With each page table entry a valid–invalid bit is associated (1  in-memory, 0  not-in-memory) Initially valid–invalid but is set to 0 on all entries. Example of a page table snapshot. During address translation, if valid–invalid bit in page table entry is 0  page fault  Frame #valid-invalid bit page table

03/26/2010CSCI 315 Operating Systems Design7 Page Table when some pages are not in Main Memory

03/26/2010CSCI 315 Operating Systems Design8 Page Fault If there is ever a reference to a page, first reference will trap to OS  page fault. OS looks at page table to decide: –If it was an invalid reference  abort. –If it was a reference to a page that is not in memory, continue. Get an empty frame. Swap page into frame. Correct the page table and make validation bit = 1. Restart the instruction that caused the page fault.

03/26/2010CSCI 315 Operating Systems Design9 Steps in Handling a Page Fault

03/26/2010CSCI 315 Operating Systems Design10 No free frame: now what? Page replacement: Are all those pages in memory being referenced? Choose one to swap back out to disk and make room to load a new page. –Algorithm: How you choose a victim. –Performance: Want an algorithm that will result in minimum number of page faults. Side effect: The same page may be brought in and out of memory several times.

03/26/2010CSCI 315 Operating Systems Design11 Performance of Demand Paging 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) (memory access)] + [p (page fault overhead)] where: page fault overhead = [swap page out ] + [swap page in] + [restart overhead]

03/26/2010CSCI 315 Operating Systems Design12 Page Replacement Prevent over-allocation of memory by modifying page- fault service routine to include page replacement. Use modify (dirty) bit to reduce overhead of page transfers – only modified pages are written to disk. Page replacement completes separation between logical memory and physical memory – large virtual memory can be provided on a smaller physical memory.

03/26/2010CSCI 315 Operating Systems Design13 Need For Page Replacement

03/26/2010CSCI 315 Operating Systems Design14 Basic Page Replacement 1.Find the location of the desired page on disk. 2.Find a free frame: - If there is a free frame, use it. - If there is no free frame, use a page replacement algorithm to select a victim frame. 3.Read the desired page into the (newly) free frame. Update the page and frame tables. 4.Restart the process.

03/26/2010CSCI 315 Operating Systems Design15 Page Replacement

03/26/2010CSCI 315 Operating Systems Design16 Page Replacement Algorithms Goal: Produce a low page-fault rate. Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string. The reference string is produced by tracing a real program or by some stochastic model. We look at every address produced and strip off the page offset, leaving only the page number. For instance: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

03/26/2010CSCI 315 Operating Systems Design17 Graph of Page Faults Versus The Number of Frames

03/26/2010CSCI 315 Operating Systems Design18 FIFO Page Replacement Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5. 3 frames (3 pages can be in memory at a time per process) 4 frames FIFO Replacement  Belady’s Anomaly: more frames, more page faults page faults page faults 4 43

03/26/2010CSCI 315 Operating Systems Design19 FIFO Page Replacement

03/26/2010CSCI 315 Operating Systems Design20 FIFO (Belady’s Anomaly)

03/26/2010CSCI 315 Operating Systems Design21 Optimal Algorithm Replace the page that will not be used for longest period of time. (How can you know what the future references will be?) 4 frames example: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 Used for measuring how well your algorithm performs page faults 4 5

03/26/2010CSCI 315 Operating Systems Design22 Optimal Page Replacement