Chapter 3 Memory Management

Slides:



Advertisements
Similar presentations
Chapter 1 The Study of Body Function Image PowerPoint
Advertisements

Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Chapter 5 Input/Output 5.4 Disks
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc
Chapter 4 Memory Management Basic memory management Swapping
Project 5: Virtual Memory
CS 241 Spring 2007 System Programming 1 Memory Replacement Policies Lecture 32 Klara Nahrstedt.
Page Replacement Algorithms
Chapter 3.3 : OS Policies for Virtual Memory
Virtual Memory 3 Fred Kuhns
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Module 10: Virtual Memory
Chapter 10: Virtual Memory
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 II Chapter 8.
Memory Management.
Page Replacement Algorithms
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
Memory management Lecture 7 ~ Winter, 2007 ~.
Memory Management Paging &Segmentation CS311, CS350 & CS550.
Chapter 9: Virtual Memory
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
MODERN OPERATING SYSTEMS Third Edition ANDREW S
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.
1 Pertemuan 16 Isu-Isu pada Sistem Paging dan Segmentasi Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5.
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.
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.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
CSC 322 Operating Systems Concepts Lecture - 15: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Maninder Kaur VIRTUAL MEMORY 24-Nov
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Memory Management Page replacement algorithms, segmentation Tanenbaum, ch. 3 p Silberschatz, ch. 8, 9 p
Memory Management From Chapter 4, Modern Operating Systems, Andrew S. Tanenbaum.
Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved OPERATING SYSTEMS DESIGN.
Memory Management 3 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
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.
Chapter 4 Memory Management Virtual Memory.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
Lecture Topics: 11/24 Sharing Pages Demand Paging (and alternative) Page Replacement –optimal algorithm –implementable algorithms.
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 内存管理.
1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples (not covered.
1 Memory Management Chapter Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement.
10.1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples.
1 Memory Management Adapted From Modern Operating Systems, Andrew S. Tanenbaum.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
Memory Management Chapter 3
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Memory Management Paging (continued) Segmentation
Session 3 Memory Management
Chapter 9: Virtual Memory – Part I
Modeling Page Replacement Algorithms
Module 9: Virtual Memory
CSE306 Operating Systems Lecture #4 Memory Management
Chapter 9: Virtual-Memory Management
Module 2.2 COP4600 – Operating Systems Richard Newman
Page Replacement.
Memory Management Paging (continued) Segmentation
Modeling Page Replacement Algorithms
Chapter 4: Memory Management
CSE 542: Operating Systems
Memory Management Paging (continued) Segmentation
Module 9: Virtual Memory
Virtual Memory.
Chapter 8 & 9 Main Memory and Virtual Memory
CSE 542: Operating Systems
Presentation transcript:

Chapter 3 Memory Management 3.4 - 3.6 Page Replacement Algorithms Design Issues Implementation

Page Replacement Algorithms Optimal page replacement algorithm Not recently used page replacement First-In, First-Out page replacement Second chance page replacement Clock page replacement Least recently used page replacement Working set page replacement WSClock page replacement Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Second Chance Algorithm Figure 3-15. Operation of second chance. (a) Pages sorted in FIFO order. (b) Page list if a page fault occurs at time 20 and A has its R bit set. The numbers above the pages are their load times. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

The Clock Page Replacement Algorithm Figure 3-16. The clock page replacement algorithm. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

LRU Page Replacement Algorithm Figure 3-17. LRU using a matrix when pages are referenced in the order 0, 1, 2, 3, 2, 1, 0, 3, 2, 3. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Simulating LRU in Software Figure 3-18. The aging algorithm simulates LRU in software. Shown are six pages for five clock ticks. The five clock ticks are represented by (a) to (e). Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Working Set Page Replacement (1) Figure 3-19. The working set is the set of pages used by the k most recent memory references. The function w(k, t) is the size of the working set at time t. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Working Set Page Replacement (2) Figure 3-20. The working set algorithm. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

The WSClock Page Replacement Algorithm (1) When the hand comes all the way around to its starting point there are two cases to consider: At least one write has been scheduled. No writes have been scheduled. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

The WSClock Page Replacement Algorithm (2) Figure 3-21. Operation of the WSClock algorithm. (a) and (b) give an example of what happens when R = 1. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

The WSClock Page Replacement Algorithm (3) Figure 3-21. Operation of the WSClock algorithm. (c) and (d) give an example of R = 0. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Summary of Page Replacement Algorithms Figure 3-22. Page replacement algorithms discussed in the text. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

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

Local versus Global Allocation Policies (2) Figure 3-24. Page fault rate as a function of the number of page frames assigned. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

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

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

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

Page Fault Handling (1) 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 Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Page Fault Handling (2) 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. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Page Fault Handling (3) 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. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

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

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

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

Separation of Policy and Mechanism (1) Memory management system is divided into three parts: A low-level MMU handler. A page fault handler that is part of the kernel. An external pager running in user space. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Separation of Policy and Mechanism (2) Figure 3-30. Page fault handling with an external pager. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639