Memory Management 3 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.

Slides:



Advertisements
Similar presentations
Chapter 3 Memory Management
Advertisements

Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 36 Virtual Memory Read.
Memory Management Paging &Segmentation CS311, CS350 & CS550.
Chapter 9: Virtual Memory
Virtual Memory Management G. Anuradha Ref:- Galvin.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
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.
CSC 322 Operating Systems Concepts Lecture - 18: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Memory Management Design & Implementation Segmentation Chapter 4.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
1 Pertemuan 16 Isu-Isu pada Sistem Paging dan Segmentasi Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5.
Chapter 3.2 : Virtual Memory
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved The Operating System Machine.
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.
Memory Management 2 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
A. Frank - P. Weisberg Operating Systems Simple/Basic Segmentation.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Chapter 3 Memory Management 3.7 Segmentation. A compiler has many tables that are built up as compilation proceeds, possibly including: The source text.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Virtual Memory.
CS333 Intro to Operating Systems Jonathan Walpole.
Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved OPERATING SYSTEMS DESIGN.
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Page 110/20/2015 CSE 30341: Operating Systems Principles So far…  Page  Fixed size pages solve page allocation problem (and external fragmentation) 
Memory Management 1 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
1 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms.
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Chapter 4 Memory Management Virtual Memory.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
Chapter 4 Memory Management Segmentation. (a) One address space. (b) Separate I and D spaces. Separate Instruction and Data Spaces.
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.
操作系统原理 OPERATING SYSTEM Chapter 3 Memory Management 内存管理.
Page Replacement Implementation Issues Text: –Tanenbaum ch. 4.7.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
1 Memory Management Chapter Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement.
Memory Management Chapter 3
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Virtual Memory CSSE 332 Operating Systems
Memory Management Paging (continued) Segmentation
Session 3 Memory Management
Chapter 9: Virtual Memory – Part I
Chapter 9: Virtual Memory
Modeling Page Replacement Algorithms
Page Replacement Implementation Issues
Module 9: Virtual Memory
Chapter 9: Virtual-Memory Management
Page Replacement.
Memory Management Paging (continued) Segmentation
5: Virtual Memory Background Demand Paging
Main Memory Background Swapping Contiguous Allocation Paging
Page Replacement Implementation Issues
Modeling Page Replacement Algorithms
Chapter 9: Virtual Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management Paging (continued) Segmentation
Module 9: Virtual Memory
CSE 542: Operating Systems
Presentation transcript:

Memory Management 3 Tanenbaum Ch. 3 Silberschatz Ch. 8,9

cs431-cotter2 Figure Local versus global page replacement. (a) Original configuration. (b) Local page replacement. (c) Global page replacement. Local versus Global Allocation Policies (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter3 Figure Page fault rate as a function of the number of page frames assigned. Setting Page Fault Rates Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter4 Figure (a) One address space. (b) Separate I and D spaces. Separate Instruction and Data Spaces Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter5 Figure Two processes sharing the same program sharing its page table. Shared Pages Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter6 Figure A shared library being used by two processes. Shared Libraries Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter7 Page Fault Management CPU Physical Memory f p { pd df physical address OS

cs431-cotter8 Page Fault Management CPU Physical Memory f p { pd df physical address OS

cs431-cotter9 Page Fault Management CPU Physical Memory f p { pd df physical address OS

cs431-cotter10 Page Fault Management CPU Physical Memory f p { pd df physical address OS

cs431-cotter11 Page Fault Management CPU Physical Memory f p { pd df physical address OS

cs431-cotter12 Page Fault Management CPU Physical Memory f p { pd df physical address OS

cs431-cotter13 Page Fault Management CPU Physical Memory f p { pd df physical address OS

cs431-cotter14 The hardware traps to the kernel, saving the program counter on the stack. An assembly code routine is started to save the general registers and other volatile information. The operating system discovers that a page fault has occurred, and tries to discover which virtual page is needed. Once the virtual address that caused the fault is known, the system checks to see if this address is valid and the protection consistent with the access Page Fault Handling (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter15 If the page frame selected is dirty, the page is scheduled for transfer to the disk, and a context switch takes place. When page frame is clean, operating system looks up the disk address where the needed page is, schedules a disk operation to bring it in. When disk interrupt indicates page has arrived, page tables updated to reflect position, frame marked as being in normal state. Page Fault Handling (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter16 Faulting instruction backed up to state it had when it began and program counter reset to point to that instruction. Faulting process scheduled, operating system returns to the (assembly language) routine that called it. This routine reloads registers and other state information and returns to user space to continue execution, as if no fault had occurred. Page Fault Handling (3) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter17 Paging Hardware support for paging –page table v/i bit –swap space (hard disk) Saving Swapped pages –If page has not been modified, just overwrite. –If page has been modified, write to swap space. Locality of Reference –Spatial locality –Temporal locality

cs431-cotter18 Paging Performance Page fault rate 0 <= p <= 1 –0 = no page faults –1 = always page fault Effective Access Time –EAT = (1 - p) * memory access + p ( page fault overhead + [swap page out] + swap page in + restart overhead)

cs431-cotter19 Performance Examples Parameters: –memory access time = 20 ns = 0.02  sec –50% of pages swapped have been modified –Page Swap time: 10 msec = 10,000  sec –p = 0.01; Performance EAT =.99 * * 15,000 =  sec

cs431-cotter20 Performance Examples Parameters: –memory access time = 20 ns = 0.02  sec –50% of pages swapped have been modified –Page Swap time: 10 msec = 10,000  sec –p = 0.01; Performance EAT =.99 * * 15,000 =  sec EAT = * * 15,000 = =  sec = 35 ns

cs431-cotter21 Page Replacement Find the desired page on the disk Find a free frame –If there is a free frame, use it –If not, use some algorithm to find a "victim" –Write the victim page to disk and update page table Read in desired page from disk Restart user process

cs431-cotter22 Figure An instruction causing a page fault. Instruction Backup Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter23 Figure (a) Paging to a static swap area. Backing Store (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter24 Figure (b) Backing up pages dynamically. Backing Store (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter25 A compiler has many tables that are built up as compilation proceeds, possibly including: The source text being saved for the printed listing (on batch systems). The symbol table – the names and attributes of variables. The table containing integer, floating-point constants used. The parse tree, the syntactic analysis of the program. The stack used for procedure calls within the compiler. Segmentation (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter26 Figure In a one-dimensional address space with growing tables, one table may bump into another. Segmentation (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter27 Figure A segmented memory allows each table to grow or shrink independently of the other tables. Segmentation (3) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter28 Figure Comparison of paging and segmentation. Implementation of Pure Segmentation Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter29 Figure (a)-(d) Development of checkerboarding. (e) Removal of the checkerboarding by compaction. Segmentation with Paging: MULTICS (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter30 Figure The MULTICS virtual memory. (a) The descriptor segment points to the page tables. Segmentation with Paging: MULTICS (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter31 Figure The MULTICS virtual memory. (b) A segment descriptor. The numbers are the field lengths. Segmentation with Paging: MULTICS (5) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter32 Figure A 34-bit MULTICS virtual address. Segmentation with Paging: MULTICS (8) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter33 When a memory reference occurs, the following algorithm is carried out: The segment number used to find segment descriptor. Check is made to see if the segment’s page table is in memory. –If not, segment fault occurs. –If there is a protection violation, a fault (trap) occurs. Segmentation with Paging: MULTICS (6) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter34 Page table entry for the requested virtual page examined. –If the page itself is not in memory, a page fault is triggered. –If it is in memory, the main memory address of the start of the page is extracted from the page table entry The offset is added to the page origin to give the main memory address where the word is located. The read or store finally takes place. Segmentation with Paging: MULTICS (7) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter35 Figure Conversion of a two-part MULTICS address into a main memory address. Segmentation with Paging: MULTICS (9) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter36 Figure A simplified version of the MULTICS TLB. The existence of two page sizes makes the actual TLB more complicated. Segmentation with Paging: MULTICS (10) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

cs431-cotter37 Summary Frame Allocation Policies –Local vs. Global –Instruction vs. data Page Fault Management Segmentation

cs431-cotter38 Questions What is the effective memory access time in a system with a memory access time of 20 ns, a disk access time of 8 ms, and a page fault rate of 1*10 -6 ? Programs today are so large, and memory is small (relative to the size of all of the programs needed at one time). A paging system needs to ensure that pages needed by the CPU are usually in main memory. Why? (Include in your explanation the penalty that a program suffers if the page is not in main memory). What mechanism in normal programs makes paging an acceptable solution? (Why don't we have many page faults?) What is the difference between paging and segmentation? What are the advantages and disadvantages of each? How can OSs use a pure paging scheme in CPUs that implement segmentation?