Lecture 38 Syed Mansoor Sarwar

Slides:



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

Chapter 10: Virtual Memory
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.
Virtual Memory Management G. Anuradha Ref:- Galvin.
Virtual Memory Operating System Concepts chapter 9 CS 355
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.
Chapter 9: Virtual-Memory Management. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 9: Virtual Memory Background Demand Paging.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Virtual-Memory Management
Virtual Memory CS 3100 Virutal Memory.
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.
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 9: Virtual Memory. Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
Chapter 9: Virtual-Memory Management. 9.2Operating System Principles Chapter 9: Virtual-Memory Management Background Demand Paging Copy-on-Write Page.
Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Background Virtual memory –
Computer Studies (AL) Memory Management Virtual Memory I.
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 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 9: Virtual Memory Background.
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.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Outline n Background n Demand.
Chapter 9: Virtual Memory. 9.2 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped.
CSC 360, Instructor: Kui Wu Memory Management II: Virtual Memory.
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.
Lecture 19 Virtual Memory Demand Paging. Background Virtual memory – separation of user logical memory from physical memory. –Only part of the program.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
Chapter 9: Virtual-Memory Management. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 9: Virtual-Memory Management 9.1 Background.
9.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 9: Virtual Memory.
1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples (not covered.
Chapter 9: Virtual Memory. Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Chapter 9: Virtual Memory. Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 9: Virtual 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
CSC 322 Operating Systems Concepts Lecture - 16: by
Lecture 45 Syed Mansoor Sarwar
Virtual Memory.
Chapter 9: Virtual Memory
Operating Systems Lecture November 2018.
Lecture 39 Syed Mansoor Sarwar
What Happens if There is no Free Frame?
Lecture 40 Syed Mansoor Sarwar
Lecture 32 Syed Mansoor Sarwar
Chapter 9: Virtual Memory
Lecture 36 Syed Mansoor Sarwar
Chapter 6 Virtual Memory
Lecture 37 Syed Mansoor Sarwar
Operating Systems CMPSC 473
Lecture 35 Syed Mansoor Sarwar
Chapter 9: Virtual Memory
Chapter 9: Virtual Memory
Presentation transcript:

Lecture 38 Syed Mansoor Sarwar Operating Systems Lecture 38 Syed Mansoor Sarwar

© Copyright Virtual University of Pakistan Agenda for Today Review of previous lecture Performance of Demand Paging Process Creation Memory Mapped Files 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Review of Lecture 37 Memory Management in Intel 80386 Virtual Memory Concept Hardware Support Demand Paging Page Fault Performance of Demand Paging 7 December 2018 © Copyright Virtual University of Pakistan

Intel 80386 Example 16-bit Selector 32-bit Offset s g p 13-bit Segment # s g p 2-bit field for specifying the privilege level 1-bit field to specify GDT or LDT 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Intel 80386 Example 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Demand Paging 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Servicing a Page Fault 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Block/String Move 1 Destination String Source String 2 3 … 7 December 2018 © Copyright Virtual University of Pakistan

Performance of Demand Paging Effective Access Time (EAT) EAT = (1 – p) x memory access time + p (page fault service time) 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan 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. 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan 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. 7 December 2018 © Copyright Virtual University of Pakistan

Page Fault and No Free Frame Page Replacement Replacement algorithm (minimize number of page faults) Performance with replacement Victim selection Criteria Local vs. global 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Another Example Effective memory access is 100 ns Page fault overhead is 100 microseconds = 105 ns Page swap time is10 milliseconds = 107 ns 50% of the time the page to be replaced is “dirty” Restart overhead is 20 microseconds = 2 x 104 ns 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Another Example Effective access time = 100 x (1-p) + (105 + 2 x 104 + 0.5 x 107 + 0.5 x 2 x 107 ) x p = 100 x (1-p) + 15,120,000 x p 7 December 2018 © Copyright Virtual University of Pakistan

What is a Good Page Fault Rate? For the previous example suppose p is 1%, then EAT is = 100 x (1-p) + 15,120,000 x p = 151299 ns  a slowdown of 151299 / 100 = 1513 7 December 2018 © Copyright Virtual University of Pakistan

What is a Good Page Fault Rate? For the luxury of virtual memory to cost only 20% overhead, we need 120 > 100 x (1-p) + 15,120,000 x p 120 > 100 -100 p + 15,120,000 p p < 0.00000132  Less than one page fault for every 755995 memory accesses! 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Process Creation fork() Exact copy of parent’s memory image Copying parent’s pages (address space) Child may call exec() immediately  copying parent’s address space is not needed 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Process Creation “Copy-on-write”  child share’s parent’s address space and pages which may change are marked “copy-on-write” When a process tries to modify a page, it is copied and inserted in the page table for the process Used in Windows 2000, Solaris 2, and Linux 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Process Creation vfork() Parent is suspended and child uses parent’s address space Pages altered by the child process are visible to parent Intended to be used when child process calls exec() immediately after its creation 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Linux Implementation Shared pages are marked readonly after fork() If either process tries to modify a shared page, a page fault occurs and the page is copied. The other process (who later faults on write) discovers it is the only owner; so no copying takes place. 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan 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. A file is initially read using demand paging. A page-sized portion of the file is read from the file system into a physical page. Subsequent reads/writes from/to the file are treated as ordinary memory accesses. 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Memory-Mapped Files Simplifies file access by treating file I/O through memory rather than read() write() system calls. Also allows several processes to map the same file allowing the pages in memory to be shared. Some operating systems only provide memory-mapping through a system call (mmap()). Others treat all file I/O as memory mapped files. 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Memory-Mapped Files 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan mmap() System Call “Normal” File I/O fildes = open(...); lseek(...); read(fildes, buf, len); /* use data in buf */ File I/O with mmap() fildes = open(...) address = mmap((caddr_t) 0, len,(PROT_READ | PROT_WRITE), MAP_PRIVATE, fildes, offset); /* use data at address */ 7 December 2018 © Copyright Virtual University of Pakistan

Memory-Mapped Files in Solaris 2 If file is opened as memory mapped: it maps the file to the address space of the process. If the file is opened non memory-mapped, Solaris 2 opens it as a memory-mapped file, mapping it to the kernel address space 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Recap of Lecture Performance of Demand Paging Process Creation Memory Mapped Files 7 December 2018 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Operating Systems Lecture 38 Syed Mansoor Sarwar 7 December 2018 © Copyright Virtual University of Pakistan