1 10.5 Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.

Slides:



Advertisements
Similar presentations
Module 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.
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
1 CSC 539: Operating Systems Structure and Design Spring 2005 Virtual memory  background  demand paging  page replacement: FIFO, OPT, LRU  allocation.
Virtual Memory Management G. Anuradha Ref:- Galvin.
Allocation of Frames Each process needs minimum number of pages
Operating Systems Prof. Navneet Goyal Department of Computer Science & Information Systems BITS, Pilani.
Page 15/4/2015 CSE 30341: Operating Systems Principles Allocation of Frames  How should the OS distribute the frames among the various processes?  Each.
1 Virtual Memory Management B.Ramamurthy. 2 Demand Paging Main memory LAS 0 LAS 1 LAS 2 (Physical Address Space -PAS) LAS - Logical Address.
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.
Segmentation and Paging Considerations
Gordon College Stephen Brinton
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)
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Virtual Memory.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Lecture 11: Memory Management
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.
Virtual Memory Chapter 8.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
1 Lecture 9: Virtual Memory Operating System I Spring 2007.
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.
1 Virtual Memory Management B.Ramamurthy Chapter 10.
OS Spring’04 Virtual Memory: Page Replacement Operating Systems Spring 2004.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
CSS430 Virtual Memory Textbook Ch9
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
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.
MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.
Chapter 10 Memory Management Part_1. 2 Overview Basic Concepts The major tasks of the memory manger are the allocation and deallocation of main memory.
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.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
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.
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.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
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.
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.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory.
Virtual Memory Chapter 8.
OPERATING SYSTEM CONCEPTS AND PRACTISE
ITEC 202 Operating Systems
Chapter 9: Virtual Memory
Operating Systems Virtual Memory Alok Kumar Jagadev.
Lecture 10: Virtual Memory
Module 9: Virtual Memory
Chapter 9: Virtual Memory
Chapter 9: Virtual-Memory Management
5: Virtual Memory Background Demand Paging
Chapter 9: Virtual Memory
Contents Memory types & memory hierarchy Virtual memory (VM)
Module 9: Virtual Memory
Virtual Memory.
Presentation transcript:

Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes advantage of the typical behavior of a process: not all blocks of the process are needed during the execution of a process. Therefore, the physical address space of a process is smaller than its logical address space.

2 Virtual Memory (2) For example, a process has 15 pages and only 7 frames are allocated.

3 Virtual Memory Principles A process can execute without having all its pages in physical memory. Some advantages are: A user process can be larger than physical memory Higher degree of multiprogramming Less I/O for loading and unloading for individual user processes Higher CPU utilization and throughput.

4 Address Space The virtual address space of a process is the entire set of all its addresses in the absolute program. After linkage, the absolute version of the program is stored on disk. The disk area that stores all the processes in absolute form is called the virtual memory The physical address space of a process is much smaller than its virtual address because only a portion of the process will ever be loaded into main memory.

Address Translation in VM 5

6 Referencing A Page A page reference is the page that has the address being referenced. The virtual memory manager swaps in a page of an executing process whenever the execution of a process references a page that is not in physical memory. Any unused page in physical memory will normally be swapped out to disk.

Paging Policies Fetch policy -- decides when a page should be loaded into memory Replacement policy -- decides which page in memory should be replaced Placement policy -- decides where in memory should a page be loaded

Page Faults and Performance Issues A page fault requires the operating system to carry out the page fault service. The total time it takes to service a page fault includes several time components: The time interval to service the page fault interrupt. The time interval to store back (swap out) the replaced page to the secondary storage device. The time interval to load (swap in) the referenced page from the secondary storage device (disk unit). Delay in queuing for the secondary storage device. Delay in scheduling the process with the referenced page.

Page Replacement When there is a page fault, the referenced page must be loaded If there is no available frame in memory one page is selected for replacement. If the selected page has been modified, it must be copied back to disk (swapped out)

10 Handling Of A Page Fault 1.For every page reference, the page table entry for the page referenced is examined. If the access is invalid, the process is terminated. 2.If the referenced page is not in memory, a page fault occurs and the OS interrupts the process 3.The OS handles the page fault 1.carries out the page replacement. 2.Swaps out the replaced page 3.Swaps in the referenced page 4.Reschedules the process that caused the page fault 4.The instruction which caused the page fault is restarted when the process resumes execution.

11 PAGE REPLACEMEMT ALGORITHMS Goal: to minimize the page fault rate. Input: – size of the process in pages – number of page frames allocated – a set of page reference strings Output: number of page faults

Static Replacement Algorithms The static paging algorithms implement the replacement policy when the frame allocation to a process is fixed. The three most common static paging algorithms: – First-in-first-out (FIFO) replacement – Optimal replacement – Least recently used (LRU) replacement

FIFO Algorithm When a page fault occurs and there are no empty frames for the process, the page selected to be replaced is the one that has been in memory the longest time, the oldest page. This selection of the page to replace is completely independent of the locality of the process. Thus, it does not follow very well the general behavior of processes.

14 FIFO Example

15 Optimal Algorithm The optimal algorithm for page replacement requires knowledge of the entire page reference stream in advance. When a page fault occurs and there are no empty frames for the process, the algorithm looks ahead in the page reference stream to find out about future references to the pages currently in physical memory. The approach used is to replace the page in memory that will not be used for the longest period.

16 Optimal Example

17 LRU Algorithm The least recently used (LRU) replacement algorithm replaces the page that has not been used for the longest period. The assumption is that recent page references give a good estimation of page references in the near future. When a page fault occurs and there are no empty frames the algorithm selects the least recently referenced page for replacement.

18 LRU Example

Dynamic Paging Algorithms The previous algorithms assume that a process is allocated a fixed amount of frames from the start of execution. Dynamic paging algorithms attempt to adjust the memory allocation to match the process’ needs as it executes The Working Set algorithm is the best known algorithm for dynamic paging.

20 The Working Set Model The working set for each model is the set of pages referenced by the process during the most recent w page references The working set window is w, which is difficult to determine. Ideally, w is chosen so that at any time, the working set for a process is exactly the process’ current locality

Working Set Window 21

22 Frame Allocation Problem If a process does not have “enough” frames allocated, the page-fault rate would be very high. This leads to: Low CPU utilization The OS attempts to increase the degree of multiprogramming Thrashing -- a process spends most or all of its time swapping pages.

23 Thrashing A process is thrashing if is spending more time paging than executing A thrashing process can cause other processes to thrash if a global page replacement strategy is used. When a process incurs a page fault, a local page replacement algorithm selects for replacement some page that belongs to that same process (or a group of processes sharing a memory partition). A global replacement algorithm is free to select any page in memory. When CPU utilization is low, the OS may increase the degree of multiprogramming and cause other processes to thrash

24 Solve Thrashing To stop thrashing, each active process should be allocated enough frames for its current locality