CSC 322 Operating Systems Concepts Lecture - 16: by

Slides:



Advertisements
Similar presentations
Chapter 10: Virtual Memory
Advertisements

Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Virtual Memory Operating System Concepts chapter 9 CS 355
Page 15/4/2015 CSE 30341: Operating Systems Principles Allocation of Frames  How should the OS distribute the frames among the various processes?  Each.
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.
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
CSC 322 Operating Systems Concepts Lecture - 18: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Gordon College Stephen Brinton
Memory Management Design & Implementation Segmentation Chapter 4.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Operating System Support Focus on Architecture
Memory Management 2010.
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.
CSC 322 Operating Systems Concepts Lecture - 15: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
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.
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
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 ©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.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 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.
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 9: Virtual Memory
SLC/VER1.0/OS CONCEPTS/OCT'99
OPERATING SYSTEM CONCEPTS AND PRACTISE
Virtual Memory CSSE 332 Operating Systems
CSC 322 Operating Systems Concepts Lecture - 12: by
Chapter 9: Virtual Memory
Module 9: Virtual Memory
Chapter 9: Virtual Memory
Lecture 28: Virtual Memory-Address Translation
O.S Lecture 13 Virtual Memory.
Chapter 9: Virtual-Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
What Happens if There is no Free Frame?
5: Virtual Memory Background Demand Paging
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Chapter 9: Virtual Memory
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Chapter 9: Virtual Memory
Chapter 6 Virtual Memory
Chapter 9: Virtual Memory
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Operating Systems CMPSC 473
Chapter 9: Virtual Memory
Module 9: Virtual Memory
OPERATING SYSTEMS MEMORY MANAGEMENT BY DR.V.R.ELANGOVAN.
Chapter 9: Virtual Memory
Chapter 8 & 9 Main Memory and Virtual Memory
CSE 542: Operating Systems
Presentation transcript:

CSC 322 Operating Systems Concepts Lecture - 16: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. (Chapter-3) Ahmed Mumtaz Mustehsan, CIIT, Islamabad 1

Design Issues for Paging System Chapter 3 Memory Management Virtual Memory Design Issues for Paging System Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Design Issues for Paging System Need to take into account a number of design issues in order to get a working algorithm Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Global is better for the memory Working sets grow and shrink over time Processes have different sizes Assign equal number of pages to each process or proportional to its size ? Start with allocation based on size and use page fault frequency (PFF) to modify allocation size for each process Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Local versus Global choice of page Local-take into account just the process which faulted. Local replacement : from only its own set of allocated frames. Global-take into account all of the processes. Global replacement : process selects a replacement frame from the set of all frames; one process can take a frame from another Original configuration. Local page replacement. Global page replacement. Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad PFF used to determine page allocation Maintain upper (A) and lower (B) bounds for PFF Try to keep process in between bounds Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Local Versus Global PFF is global component; determines page allocation Replacement algorithm Is local component; determines which page to kick out Can use combination of algorithms Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad 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 Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Solution of Thrashing; Load Control Why? Can still thrash because of too much demand for memory. (local or i.e. accumulative demand of Pages) Solution-swap process(es) out .i.e. When desperate, get rid of a process Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Transfer of a Paged Memory to Contiguous Disk Space Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Thrashing (Cont.) When the number of processes in main memory is too low, the CPU may be idle for substantial periods of time. Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Other Issues – Page Size Page size selection must take into consideration: Fragmentation; wastage of ½ Page per process Page Table size; Reciprocal to page size I/O overhead; Page swap in and swap out Locality; Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Page size Overhead= s*e/p + p/2 [size of page entries + frag] p is page size, s is process size, e is size of the page entry (in page table) Differentiate, -se/p 2 + 1/2 = 0 set to zero => s= 1 MB, e=8 bytes 4 KB is optimal 1 KB is typical 4-8 KB common OK, this is a rough approach Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Separate Instruction and Data Address Spaces Process address space too small => difficult to fit program in space Split space into instructions (I) and data (D) Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Separate Instruction and Data Address Spaces Pioneer on the (16-bit) PDP- 11, address spaces for instructions (text) and data typically 216 - 1 or 232 - 1. The linker must know that a separate I & D spaces are used. Data address space runs from 0 instead after program. Both address spaces can be paged, independently. Each has its own page table, own mapping of virtual pages to physical page frames. When the hardware to fetch an instruction, it uses I-space and D-space page table respectively. Other than this distinction, no other difference. Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Shared Pages Different users can run same program (with different data) at the same time. Better to share pages then to have 2 copies! Not all pages can be shared (data can’t be shared, text can be shared) If D & I spaces have a separate process table point to I and D pages then text (I-space can easily be shared) Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Shared Pages processes A and B are sharing the editor and its pages. If the scheduler removes A from memory, evicting all its pages will cause B to generate a large number of page faults to bring back in the pages. Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad More page sharing When pages are shared, Process can’t drop pages when it exits w/o being certain that they not still in use Use special data structure to track shared pages Data sharing is painful (e.g. Unix fork, parent and child share text and data) because of page writes. So shared pages are READONLY. But if the process wants to write on shared pages? (Copy on write) solution is to map data to read only pages. If write occurs, each process gets its own page. Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Copy-on-Write Copy-on-Write (COW) allows both parent and child processes to initially share the same pages in memory If either process modifies a shared page, only then is the page copied COW allows more efficient process creation as only modified pages are copied Free pages are allocated from a pool of zeroed-out pages Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Before Process 1 Modifies Page C VM benefit during Process Creation; Copy-on-Write Before Process 1 Modifies Page C Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

After Process 1 Modifies Page C VM benefit during Process Creation; Copy-on-Write After Process 1 Modifies Page C Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Shared Libraries Large libraries (e.g. graphics) used by many process. Too expensive to bind to each process which wants to use them. Use shared libraries instead. Unix linking: ld*.o –lc –lm . Files (and no others) not present in .o are located in m or c libraries and included in binaries. Write object program to disk. Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Shared Libraries Linker uses a stub routine to call which binds to called function AT RUN TIME. Shared library is only loaded once (first time that a function of it refers to that). It is paged in Need to use position independent code to avoid going to the wrong address (next slide). Idea: Compiler does not produce absolute addresses when using shared libraries; only relative addresses. Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Shared Libraries . Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Shared Library Using Virtual Memory Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Memory Mapped Files Shared libraries are a special case of a more general facility called memory-mapped files. Process issues system call to map a file onto a part of its virtual address space. Can be used to communicate via shared memory. Processes share same file. Use it to read and write. Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad 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 to/from the file are treated as ordinary memory accesses. 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. Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Memory Mapped Files Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Performance Issues Cleaning Policy; (If there is no free frame?) Page Replacement Allocation of Frames Priority Allocation How to increase TLB Reach ? Lecture-16 Ahmed Mumtaz Mustehsan, CIIT, Islamabad