Lecture Topics: 11/24 Sharing Pages Demand Paging (and alternative) Page Replacement –optimal algorithm –implementable algorithms.

Slides:



Advertisements
Similar presentations
SE-292: High Performance Computing
Advertisements

9.4 Page Replacement What if there is no free frame?
Chapter 3 Memory Management
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Scribe for 7 th April 2014 Page Replacement Algorithms Payal Priyadarshini 11CS30023.
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
Virtual Memory Management G. Anuradha Ref:- Galvin.
Virtual Memory Operating System Concepts chapter 9 CS 355
Caching and Virtual Memory. Main Points Cache concept – Hardware vs. software caches When caches work and when they don’t – Spatial/temporal locality.
1 Virtual Memory Management B.Ramamurthy. 2 Demand Paging Main memory LAS 0 LAS 1 LAS 2 (Physical Address Space -PAS) LAS - Logical Address.
Virtual Memory Introduction to Operating Systems: Module 9.
Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
1 Virtual Memory vs. Physical Memory So far, all of a job’s virtual address space must be in physical memory However, many parts of programs are never.
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Paging Design.
Introduction to Systems Programming Lecture 7
Translation Buffers (TLB’s)
Virtual Memory Management B.Ramamurthy. Paging (2) The relation between virtual addresses and physical memory addres- ses given by page table.
1 Virtual Memory Management B.Ramamurthy Chapter 10.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
1 Last Time: Paging Motivation Page Tables Hardware Support Benefits.
Lecture 33: Chapter 5 Today’s topic –Cache Replacement Algorithms –Multi-level Caches –Virtual Memories 1.
Operating Systems ECE344 Ding Yuan Page Replacement Lecture 9: Page Replacement.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Virtual Memory.
Caching and Virtual Memory. Main Points Cache concept – Hardware vs. software caches When caches work and when they don’t – Spatial/temporal locality.
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.
CS 153 Design of Operating Systems Spring 2015 Lecture 17: Paging.
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
Lecture 11 Page 1 CS 111 Online Virtual Memory A generalization of what demand paging allows A form of memory where the system provides a useful abstraction.
CPS110: Page replacement Landon Cox. Replacement  Think of physical memory as a cache  What happens on a cache miss?  Page fault  Must decide what.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Demand Paging.
Demand Paging Reference Reference on UNIX memory management
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
Virtual Memory The address used by a programmer will be called a virtual address or logical address. An address in main memory is called a physical address.
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
CSE 153 Design of Operating Systems Winter 2015 Lecture 12: Page Replacement.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
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.
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a “cache” for secondary (disk) storage – Managed jointly.
Operating Systems ECE344 Ding Yuan Page Replacement Lecture 9: Page Replacement.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
CS 333 Introduction to Operating Systems Class 14 – Page Replacement
CS161 – Design and Architecture of Computer
Logistics Homework 5 will be out this evening, due 3:09pm 4/14
Memory Management (2).
CS161 – Design and Architecture of Computer
Chapter 9: Virtual Memory – Part I
Modeling Page Replacement Algorithms
Chapter 9: Virtual Memory
Chapter 9: Virtual-Memory Management
Page Replacement.
Lecture 39 Syed Mansoor Sarwar
Demand Paged Virtual Memory
Modeling Page Replacement Algorithms
Contents Memory types & memory hierarchy Virtual memory (VM)
Translation Buffers (TLB’s)
Page Allocation and Replacement
Virtual Memory: Working Sets
Lecture 9: Caching and Demand-Paged Virtual Memory
CSE 542: Operating Systems
Translation Buffers (TLBs)
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Review What are the advantages/disadvantages of pages versus segments?
Virtual Memory.
Chapter 8 & 9 Main Memory and Virtual Memory
CSE 542: Operating Systems
Module IV Memory Organization.
Presentation transcript:

Lecture Topics: 11/24 Sharing Pages Demand Paging (and alternative) Page Replacement –optimal algorithm –implementable algorithms

Redundancy in Memory A lot of times, we run more than one instance of the same program –more than one editor session –more than one server process –more than one of anything after a fork() The virtual address spaces will contain redundant data Physical memory may contain redundant data

Shared Pages With paged virtual memory, an easy fix Just make both page tables point to the same page frame for shared data Reserved Text Static data Dynamic data and stack Reserved Text Static data Dynamic data and stack emacs #1emacs #2phys mem

The Life Cycle of Process VM When a process starts, its page table contains no valid mappings –This is after exec() in unix The contents of virtual memory are known, but not resident in physical memory Data only comes from two places –Disk (program image, static data) –Zero (stack pages, heap)

Demand Paging When the new process begins to run –The PC is set to the beginning of the first text page –Try to fetch the first instruction –The instruction’s virtual address is sent to the MMU –No VPN->PPN mapping is found in the TLB –The page table entry is marked invalid –Trap to the OS - page fault!

Page Fault Handling The OS must deal with invalid page table entries: –copy the code page from disk to memory –update the page table entry and mark it valid –insert the mapping into the TLB –return to the application

The Process Keeps Running... As the process runs, it touches new pages Each new page is faulted in by the OS If it is a code or static data page, it comes from the program executable If it is a stack or heap page, it is filled with zeros Can also map a file into memory

Alternative to Demand Paging Unsuprising that the first page faulted is always the first code page Why not just copy the executable into memory when you start the process? –Or at least a little bit of it Take it another step –Any time you have a good idea that a page will be needed soon, go ahead and get it This is called prefetching

Page Replacement Eventually, memory will fill up Some page will have to be evicted to free up a page frame for another page We have to choose the victim –Should we choose globally or from this process alone? –Once the set of potential victims is selected, which page makes the best victim?

Choosing a Victim The theoretical answer is clear: –The best victim is the page not needed for the longest time in the future One problem: we (usually) don’t know the future We can use locality to get some ideas about the future, as in higher-level caches –this motivates LRU (least recently used)

LRU and Approximations In higher level caches, we avoided LRU because it was too difficult/expensive to do in hardware Page replacement is executed in software; we have more resources Still, it’s usually better just to approximate LRU –The results are often just as good –Less computation in the critical path –Too hard to get accurate “U” information

FIFO with Second Chance FIFO = First in, First out –Not at all a good LRU approximation –No knowledge of use In FIFO with second chance, make two queues: –FIFO queue big, 2nd chance queue small –Pages move from FIFO queue to 2nd chance queue –Pages on 2nd chance queue move back to FIFO queue if used, otherwise evicted