计算机系 信息处理实验室 Lecture 10 Memory Management(2)

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

Chapter 9: Virtual Memory
计算机系 信息处理实验室 Lecture 9 Memory Management(1)
计算机系 信息处理实验室 Lecture 3 System Mechanisms (1)
國立台灣大學 資訊工程學系 Chapter 9: Virtual Memory. 資工系網媒所 NEWS 實驗室 Objectives To describe the benefits of a virtual memory system To explain the concepts of demand.
G Robert Grimm New York University Virtual Memory.
Virtual Memory Management G. Anuradha Ref:- Galvin.
计算机系 信息处理实验室 Lecture 5 Startup and Shutdown
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.
Virtual Memory Introduction to Operating Systems: Module 9.
计算机系 信息处理实验室 Leture1 concepts and tools 2005 Spring 陈香兰.
计算机系 信息处理实验室 Lecture 8 Processes, Threads, and Jobs (2)
计算机系 信息处理实验室 Lecture 11 Security
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
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.
Computer Organization and Architecture
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
1 Virtual Memory Management B.Ramamurthy Chapter 10.
Chapter 9: Virtual Memory. Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
计算机系 信息处理实验室 Lecture 14 Cache Manager
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
计算机系 信息处理实验室 Lecture 12 I/O System
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Windows 2000 Memory Management Computing Department, Lancaster University, UK.
计算机系 信息处理实验室 Lecture 7 Processes, Threads, and Jobs (1)
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
Operating Systems Unit 8: – Virtual Memory management Operating Systems.
计算机系 信息处理实验室 Lecture 6 Management Mechanisms
计算机系 信息处理实验室 Lecture 4 System Mechanisms (2)
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.
Computer Studies (AL) Memory Management Virtual Memory I.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
Virtual Memory 1 Chapter 13. Virtual Memory Introduction Demand Paging Hardware Requirements 4.3 BSD Virtual Memory 4.3 BSD Memory Management Operations.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Page Replacement Allocation of.
Virtual Memory. Background Virtual memory is a technique that allows execution of processes that may not be completely in the physical memory. Virtual.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Demand Paging.
CSC 360, Instructor: Kui Wu Memory Management II: Virtual Memory.
CS307 Operating Systems Virtual Memory Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
Windows XP Memory Management Aaron Lanoy and Jason Farnsworth.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual-Memory Management.
COS 318: Operating Systems Virtual Memory Design Issues.
Unit OS5: Memory Management
Chapter 9: Virtual Memory
Virtual Memory Chapter 8.
SLC/VER1.0/OS CONCEPTS/OCT'99
Virtual Memory CSSE 332 Operating Systems
UNIT–IV: Memory Management
Chapter 9: Virtual Memory – Part I
ITEC 202 Operating Systems
Chapter 9: Virtual Memory
Virtual Memory Management
Chapter 9: Virtual-Memory Management
Page Replacement.
Chapter 9: Virtual Memory
Chapter 9: Virtual Memory
Chapter 6 Virtual Memory
Contents Memory types & memory hierarchy Virtual memory (VM)
Chapter 9: Virtual Memory
Brown Bag Seminar FALL 2006 MEMORY MANAGEMENT
CSE 542: Operating Systems
Presentation transcript:

计算机系 信息处理实验室 Lecture 10 Memory Management(2)

计算机系 信息处理实验室 the Inside of Windows Contents Memory Manager Components Services the Memory Manager Provides System Memory Pools Address Space Layout Address Translation Page Fault Handling Virtual Address Descriptors Working Sets Page Frame Number Database Section Objects

计算机系 信息处理实验室 the Inside of Windows Page Fault Handling Page fault | |  Kernel trap handler | |  Memory manager: fault handler

计算机系 信息处理实验室 the Inside of Windows Page fault conditions Page fault can be caused by a variety of conditions See table 7-14table 7-14

计算机系 信息处理实验室 the Inside of Windows basic invalid PTEs Page file The desired page resides within a paging file. An in-page operation is initiated

计算机系 信息处理实验室 the Inside of Windows basic invalid PTEs Demand zero A page of zeros The pager : zero page list | |  free list | |  standby list PTE format : zeros the page file number and offset in the former format

计算机系 信息处理实验室 the Inside of Windows basic invalid PTEs Transition The desired page is in memory the standby, modified, or modified-no-write list The page is removed from the list and added to the working set

计算机系 信息处理实验室 the Inside of Windows basic invalid PTEs Unknown The PTE is zero, or The page table doesn't yet exist.

计算机系 信息处理实验室 the Inside of Windows Prototype PTEs For shared pages Prototype page table entries Section objects : an array of prototype PTEs First reference: Prototype PTE  real PTE Reference counter in PFN database 0  invalid the shared page

计算机系 信息处理实验室 the Inside of Windows Prototype PTEs Structure of an invalid PTE that points to the prototype PTE States of a shared page Active/valid; transition; modified-no-write; demand zero; page file; mapped file Lazy updating

计算机系 信息处理实验室 the Inside of Windows Two virtual pages (valid/invalid)

计算机系 信息处理实验室 the Inside of Windows In-Paging I/O Reading a file to satisfy a page fault In-page I/O operation Synchronous not interruptible by APC

计算机系 信息处理实验室 the Inside of Windows Collided page faults The currently being in-paged page is faulted by another thread or process A wait operation is issued When the I/O completes, all threads will be satisfied

计算机系 信息处理实验室 the Inside of Windows Page files To store modified pages because of modified page writing 2K supports up to 16 paging files EXPERIMENT Viewing system page files Viewing Page File Usage with Task Manager

计算机系 信息处理实验室 the Inside of Windows Virtual Address Descriptors Lazy evaluation Copy-on-write Demand paging Page table constructing Advantages and disadvantages

计算机系 信息处理实验室 the Inside of Windows Virtual Address Descriptors

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Viewing Virtual Address Descriptors

计算机系 信息处理实验室 the Inside of Windows Working Sets Working Set A subset of virtual pages resident in physical memory Two types Process working sets System working set

计算机系 信息处理实验室 the Inside of Windows Paging Policies How (or when) paging is performed fetch policy placement policy replacement policy

计算机系 信息处理实验室 the Inside of Windows Fetch policy When Eager-paging (Before needed) Demand-paging (Until needed) 2K Demand-paging + …. to minimize the number of paging I/Os

计算机系 信息处理实验室 the Inside of Windows Page Fault Read Clustering Values Memory Size Cluster Size for Code Pages in Images Cluster Size for Data Pages in Images Cluster Size for All Other Pages < 12 MB MB325 > 19 MB848

计算机系 信息处理实验室 the Inside of Windows Placement policy Where the size of CPU memory caches must be considered to minimize unnecessary thrashing of the cache

计算机系 信息处理实验室 the Inside of Windows Replacement policy Which Which virtual page must be removed from memory to make room for the new page Include LRU FIFO … Global or local

计算机系 信息处理实验室 the Inside of Windows K replacement policy For multiprocessor system a variation of a local FIFO For uniprocessor system Similar to LRU

计算机系 信息处理实验室 the Inside of Windows Working Set Management Default Minimum and Maximum Working Set Sizes To change: SetProcessWorkingSetSize Memory Size Default Minimum Working Set Size (in Pages) Default Maximum Working Set Size (in Pages) Small2045 Medium30145 Large50345 Maximum value must < system value MmMaximumWorkingSetSize

计算机系 信息处理实验室 the Inside of Windows Working set management When paging, it examines the process's working set limits and the amount of free memory When MmAvailablePages <= MmMinimumFreePages Must trimming working set (working set manager is called) Working set manager determines which how many

计算机系 信息处理实验室 the Inside of Windows Working Set-Related System Control Variables VariableValue MmWorkingSetSize-Increment6 MmWorkingSetSize-Expansion20 MmWsExpandThreshold90 MmPagesAboveWsMinimumDynamic MmPagesAboveWsThreshold37 MmWsAdjustThreshold45 MmWsTrimReductionGoal29

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Viewing Process Working Set Sizes Viewing the Working Set List

计算机系 信息处理实验室 the Inside of Windows Balance Set Manager and Swapper Balance set manager A system thread for Working set expansion and trimming Routine: KeBalanceSetManager Two event 1-second timer expiring Internal working set manager

计算机系 信息处理实验室 the Inside of Windows Balance set manager Every fourth time  wakes up swapper Swapper: routine (KeSwapProcessOrStack) Checks look-aside lists and adjusts their depths Looks for priority boosted threads Calls the working set manager

计算机系 信息处理实验室 the Inside of Windows Swapper Called by Balance set manager Or scheduling code Looks for threads that can be swapped out And swapped in some threads

计算机系 信息处理实验室 the Inside of Windows System Working Set five kinds of pages System cache pages Paged pool Pageable code and data in Ntoskrnl.exe Pageable code and data in device drivers System mapped views (sections mapped at 0xA , such as Win32k.sys)

计算机系 信息处理实验室 the Inside of Windows System Working Set Performance Counters Performance Counter (in Bytes) System Variable (in Pages) Memory: Cache BytesMmSystemCacheWs.WorkingSetSize Memory: Cache Bytes Peak MmSystemCacheWs.Peak Memory: System Cache Resident Bytes MmSystemCachePage Memory: System Code Resident Bytes MmSystemCodePage Memory: System Driver Resident Bytes MmSystemDriverPage Memory: Pool Paged Resident Bytes MmPagedPoolPage

计算机系 信息处理实验室 the Inside of Windows System Working Set Minimum and Maximum Size Memory Size Minimum (in Pages) Maximum (in Pages) Small Medium Large

计算机系 信息处理实验室 the Inside of Windows Page Frame Number Database the page frame number (PFN) database describes the state of each page in physical memory. States include Active/Transition/Standby/Modified/ Modified no-write/Free/Zeroed/Bad The PFN database consists of an array of structures that represent each physical page of memory on the system.

计算机系 信息处理实验室 the Inside of Windows Page tables & PFN database

计算机系 信息处理实验室 the Inside of Windows Page lists in PFN database

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Viewing the PFN Database

计算机系 信息处理实验室 the Inside of Windows Page List Dynamics state diagram for page frame transitions

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Viewing Page Fault Behavior

计算机系 信息处理实验室 the Inside of Windows Modified Page Writer writing pages back to disk, include two system threads MiModifiedPageWriter To paging file MiMappedPageWriter To mapped files The modified page writer event is triggered by the number of modified pages > MmModifiedPageMaximum Or MmAvailablePages < MmMinimumFreePages

计算机系 信息处理实验室 the Inside of Windows Modified Page Writer Values Memory SizeModified Page Threshold Retain Modified Pages < 12 MB MB MB >33 MB (special case)

计算机系 信息处理实验室 the Inside of Windows PFN Data Structures The states of a PFN entry

计算机系 信息处理实验室 the Inside of Windows Flags Within PFN Database Entries Modified state Prototype PTE Parity error Read in progress Write in progress Start of nonpaged pool End of nonpaged pool In-page error

计算机系 信息处理实验室 the Inside of Windows Section Objects section object can be mapped to the paging file or to another file on disk. Section objects, like other objects, are allocated and deallocated by the object manager

计算机系 信息处理实验室 the Inside of Windows A section object

计算机系 信息处理实验室 the Inside of Windows Internal section structures

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Viewing Section Objects Viewing Control Areas