Operating Systems Lecture 21 21 November 2018.

Slides:



Advertisements
Similar presentations
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
Advertisements

Module 10: Virtual Memory
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
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 – 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.
Virtual Memory Background Demand Paging Performance of Demand Paging
Virtual Memory Introduction to Operating Systems: Module 9.
Gordon College Stephen Brinton
Virtual Memory Management
03/26/2010CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying an earlier.
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.
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.
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.
Page 110/20/2015 CSE 30341: Operating Systems Principles So far…  Page  Fixed size pages solve page allocation problem (and external fragmentation) 
CS212: OPERATING SYSTEM Lecture 6: Virtual-Memory Management 1 Computer Science Department.
Computer Studies (AL) Memory Management Virtual Memory I.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally VIRTUALMEMORY.
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.
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.
Virtual Memory Various memory management techniques have been discussed. All these strategies have the same goal: to keep many processes in memory simultaneously.
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.
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.
Chapter 9: Virtual Memory
Topic 8 (Textbook - Chapter 9) Virtual Memory
OPERATING SYSTEM CONCEPTS AND PRACTISE
Virtual Memory CSSE 332 Operating Systems
Chapter 9: Virtual Memory – Part I
Chapter 9: Virtual Memory
Chapter 9: Virtual Memory
Operating Systems Virtual Memory Alok Kumar Jagadev.
Module 9: Virtual Memory
Chapter 9: Virtual Memory
Virtual Memory.
Chapter 9: Virtual-Memory Management
Lecture 39 Syed Mansoor Sarwar
What Happens if There is no Free Frame?
5: Virtual Memory Background Demand Paging
Lecture 38 Syed Mansoor Sarwar
Chapter 9: Virtual Memory
Chapter 9: Virtual Memory
Chapter 6 Virtual Memory
Lecture 37 Syed Mansoor Sarwar
Module 9: Virtual Memory
Chapter 9: Virtual Memory
Virtual Memory.
Module IV Memory Organization.
Presentation transcript:

Operating Systems Lecture 21 21 November 2018

Virtual Memory Virtual Memory: A technique that allows a process to execute in the main memory space which is smaller than the process size Only a part of a process needs to be loaded in the main memory for execution 21 November 2018

Fundamentals Sharing of address space among several processes Efficient process creation—fork() and vfork() Memory mapped files Support needed for virtual memory 21 November 2018

Fundamentals Virtual memory can be implemented via: Demand paging Demand segmentation 21 November 2018

The Basic Idea Secondary Storage 21 November 2018

Demand Paging Bring a page into memory only when it is needed Potentially less I/O needed Potentially less memory needed Faster response Higher degree of multiprogramming 21 November 2018

Demand Paging Page is needed  a reference is made to it Invalid reference  abort Not-in-memory  page fault  bring page to memory No free frame  swapping (out and in) 21 November 2018

Swapping 21 November 2018

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 21 November 2018

Valid-Invalid Bit During address translation, if valid–invalid bit in page table entry is 0  page fault. 1  Frame # valid-invalid bit page table 21 November 2018

Demand Paging 21 November 2018

Page Fault If there is ever a reference to a page, first reference will trap to OS  page fault OS decides Invalid reference  trap to OS  abort process Just not in memory  page fault  service page fault 21 November 2018

Page Fault Allocate an empty frame Locate the desired page on disk Swap in the desired page into the newly allocated frame. Store the frame number in the appropriate page table entry Reset tables; set valid/invalid bit to 1 Restart instruction 21 November 2018

Servicing a Page Fault 21 November 2018

Restarting Instruction Problems with restarting instructions that cause page faults Auto increment/decrement location Block move 21 November 2018

Block Move 1 Destination String Source String 2 3 … 21 November 2018

Block Move 1 Destination String Source String 2 3 … 21 November 2018

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 21 November 2018

Performance of Demand Paging Effective Access Time (EAT) EAT = (1 – p) x memory access + p (page fault service time) 21 November 2018

Page Fault Service Trap to OS Context switch Locate the vector for the given trap Check that the page reference was legal and determine the location of the desired page on the disk Locate a free frame Issue a disk read into this frame 21 November 2018

Page Fault Service While waiting for disk read to complete, schedule another process Interrupt from the disk controller indicating completion of disk read Correct the page table (frame number, in-memory bit, etc.) Put process in the ready queue Restart process with the instruction that caused page fault 21 November 2018

Example Memory access time = 100 nanosec Page fault service time = 25 millisec Teffective = (1 - p) x 100 + p (25 milli) = (1 - p) x 100 + p (25000000) = 100 + 24999900 x p If one access out of 1000 causes a page fault, effective access time is 25 microseconds, a slowdown by a factor of 250. 21 November 2018

Example If we want less than 10 percentage degradation in effective memory access time then we have the following inequality 110 > 100 + 25000000 x p 10 > 25000000 x p p < 0.0000004 This means we can allow only one page fault every 2,500,000. 21 November 2018

Process Creation “Copy-on-write”—child shares parent’s address space and is given its own copy of “copy-on-write” pages when it tries to modify them vfork()—child shares parent’s address space; useful when child invokes exec() immediately after its creation 21 November 2018

Memory-Mapped Files 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. Automatically or by using the mmap() system call on Solaris 21 November 2018

Memory-Mapped Files 21 November 2018

Page Replacement If no free frame is available on a page fault, replace a page in memory to load the desired page Page-fault service routine is modified to include page replacement. 21 November 2018

Page Replacement Use modify (dirty) bit to reduce overhead of page transfers – only modified pages are written to disk. Set by hardware when data is written to a page Checked by OS at page replacements 21 November 2018

Page Replacement 21 November 2018

Page Replacement M 21 November 2018

Page Replacement 21 November 2018