Copyright ©: Lawrence Angrave, Vikram Adve, Caccamo 1 Virtual Memory III.

Slides:



Advertisements
Similar presentations
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Advertisements

Virtual Memory: Page Replacement
Paging: Design Issues. Readings r Silbershatz et al: ,
CS 241 Spring 2007 System Programming 1 Memory Implementation Issues Lecture 33 Klara Nahrstedt.
Segmentation and Paging Considerations
CS 153 Design of Operating Systems Spring 2015
CS 153 Design of Operating Systems Spring 2015 Lecture 19: Page Replacement and Memory War.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Memory Management Design & Implementation Segmentation Chapter 4.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
Memory Management (II)
Operating System Support Focus on Architecture
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Memory Management Policies: UNIX
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Memory Management 2010.
Thrashing and Memory Management
Virtual Memory:Part 2 Kashyap Sheth Kishore Putta Bijal Shah Kshama Desai.
Memory Management April 28, 2000 Instructor: Gary Kimura.
OS Spring’04 Virtual Memory: Page Replacement Operating Systems Spring 2004.
1 Memory Management in Representative Operating Systems.
CS 241 Section Week #12 (04/22/10).
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Operating Systems ECE344 Ding Yuan Page Replacement Lecture 9: Page Replacement.
CSE378 Virtual memory.1 Evolution in memory management techniques In early days, single program ran on the whole machine –used all the memory available.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Virtual Memory.
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
Operating Systems Chapter 8
CS 241 Fall 2007 System Programming 1 Virtual Memory Lawrence Angrave and Vikram Adve.
Virtual Memory CS Introduction to Operating Systems.
Chapter 4 Storage Management (Memory Management).
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui COMP 203 / NWEN 201 Computer Organisation / Computer Architectures Virtual.
Computer Studies (AL) Memory Management Virtual Memory I.
Chapter 4 Memory Management Virtual Memory.
Copyright ©: Lawrence Angrave, Vikram Adve, Caccamo 1 Virtual Memory.
Virtual Memory. Background Virtual memory is a technique that allows execution of processes that may not be completely in the physical memory. Virtual.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Review (1/2) °Caches are NOT mandatory: Processor performs arithmetic Memory stores data Caches simply make data transfers go faster °Each level of memory.
Virtual Memory 1 1.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
Swap Space and Other Memory Management Issues Operating Systems: Internals and Design Principles.
Memory Management OS Fazal Rehman Shamil. swapping Swapping concept comes in terms of process scheduling. Swapping is basically implemented by Medium.
Page Buffering, I. Pages to be replaced are kept in main memory for a while to guard against poorly performing replacement algorithms such as FIFO Two.
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.
CSE 153 Design of Operating Systems Winter 2015 Lecture 12: Page Replacement.
NETW3005 Virtual Memory. Reading For this lecture, you should have read Chapter 9 (Sections 1-7). NETW3005 (Operating Systems) Lecture 08 - Virtual Memory2.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Operating Systems Lecture 9 Introduction to Paging Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of.
Operating Systems ECE344 Ding Yuan Page Replacement Lecture 9: Page Replacement.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
SLC/VER1.0/OS CONCEPTS/OCT'99
Memory Management.
CSE 120 Principles of Operating
CS703 - Advanced Operating Systems
Chapter 9: Virtual Memory
Main Memory Management
O.S Lecture 13 Virtual Memory.
Chapter 9: Virtual-Memory Management
Page Replacement.
CSE 451: Operating Systems Autumn 2005 Memory Management
Contents Memory types & memory hierarchy Virtual memory (VM)
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Virtual Memory: Working Sets
COMP755 Advanced Operating Systems
CSE 542: Operating Systems
Presentation transcript:

Copyright ©: Lawrence Angrave, Vikram Adve, Caccamo 1 Virtual Memory III

Working set (1968, Denning) Main idea figure out how much memory a process needs to keep most of its recent computation in memory with very few page faults How? The working set model assumes temporal locality Recently accessed pages are more likely to be accessed again Thus, as the number of page frames increases above some threshold, the page fault rate will drop dramatically

Working set (1968, Denning) What we want to know: collection of pages process must have in order to avoid thrashing This requires knowing the future. And our trick is? Intuition of Working Set: Pages referenced by process in last  seconds of execution are considered to comprise its working set  : the working set parameter Usages of working set? Cache partitioning: give each application enough space for WS Page replacement: preferably discard non-WS pages Scheduling: a process is not executed unless its WS is in memory

Working set in details At virtual time vt, the working set of a process W(vt, T) is the set of pages that the process has referenced during the past T units of virtual time. Virtual time vt is measured in terms of sequence of memory references It is easy to notice that size of working set grows as window size is increased Limitations of Working Set High overhead to maintain a moving window over memory references Past does not always predict the future correctly It is hard to identify best value for window size T Process total number of pages

Calculating Working Set 12 references, 8 faults Window size is 

Working set in details Strategy for sizing the resident set of a process based on Working set Keep track of working set of each process Periodically remove from the resident set the pages that don’t belong to working set anymore A process is scheduled for execution only if its working set is in main memory

Working set of real programs Typical programs have phases Working set size transition stable Sum of both

Page Fault Frequency (PFF) algorithm Approximation of pure Working Set Assume that working set strategy is valid; hence, properly sizing the resident set will reduce page fault rate. Let’s focus on process fault rate rather than its exact page references If process page fault rate increases beyond a maximum threshold, then increase its resident set size. If page fault rate decreases below a minimum threshold, then decrease its resident set size  Without harming the process, OS can free some frames and allocate them to other processes suffering higher PFF

Data structures for UNIX memory management To support paged virtual memory, UNIX uses following data structures: Page table (one per process) Disk block descriptor table (one per process): each virtual page has a disk block descriptor that maps it to a specific block on a swap device page frame data table: it has an entry per memory frame and it is used by the replacement algorithm

Page protection Page protection is implemented using the “protect” field in PTE For instance Write, eXecute bits enforce writing, executable permissions at the page level Check is done by hardware during each access Illegal access generates SIGSEGV

The size of swapping device We have seen that 32-bits address space corresponds to 4-Gb of virtual memory. It is important to notice that size of swap device always sets a hard limit on the total # of virtual pages that can be allocated to currently running processes

Loader and Virtual Memory At process creation the loader allocates a contigous chunk of virtual pages for.text and.data sections of its ELF executable file (stored on the disk) Actually, the loader does not copy any data from disk to main memory Quiz: what mechanism can be used to physically load the needed blocks of executable file into main memory?

Loader and Virtual Memory At process creation the loader allocates a contigous chunk of virtual pages for.text and.data sections of its ELF executable file (stored on the disk) Actually, the loader does not copy any data from disk to main memory Quiz: what mechanism can be used to physically load the needed blocks of executable file into main memory?  File memory mapping (do you remember mmap?) takes care of loading pages of an executable file during process execution

Revisiting memory mapping OS can initialize a virtual memory area by mapping it to a file on the disk (see mmap). This process is called memory mapping Memory mapping is an efficient mechanism that allows to load an executable file in main memory and to map shared objects across multiple processes Can you suggest any example of shared objects?

Revisiting memory mapping OS can initialize a virtual memory area by mapping it to a file on the disk (see mmap). This process is called memory mapping Memory mapping is an efficient mechanism that allows to load an executable in main memory and to map shared objects across multiple processes Can you suggest any example of shared objects?  Many processes have identical read-only text areas (like running multiple instances of UNIX shell tcsh)  A shared library like standard C library is another example of memory mapped object. It would be extremely inefficient to duplicate copies of shared code in physical memory  Shared memory

Revisiting memory mapping VPN0 VPN1 VPN2 VPN3 VPN4 VPN5 VPN6 VPN7 VPN8 VPN0 VPN1 VPN2 VPN3 VPN4 VPN5 VPN6 VPN7 VPN8 Process X virtual memory shared Shared object on disk The shared physical page does not have to be mapped at the same virtual address for all processes sharing it. Process Y virtual memory Page table Physical memory mapped at virt. addr.1 mapped at virt. addr.3