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

Slides:



Advertisements
Similar presentations
Numbers Treasure Hunt Following each question, click on the answer. If correct, the next page will load with a graphic first – these can be used to check.
Advertisements

Threads Chapter 4 Threads are a subdivision of processes
Chapter 8: Main Memory.
Process Description and Control
1
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Processes and Operating Systems
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 3 CPUs.
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
UNITED NATIONS Shipment Details Report – January 2006.
1 RA I Sub-Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Casablanca, Morocco, 20 – 22 December 2005 Status of observing programmes in RA I.
Chapter 5 Input/Output 5.1 Principles of I/O hardware
Chapter 6 File Systems 6.1 Files 6.2 Directories
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
1 Chapter 12 File Management Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
Photo Slideshow Instructions (delete before presenting or this page will show when slideshow loops) 1.Set PowerPoint to work in Outline. View/Normal click.
Break Time Remaining 10:00.
Figure 12–1 Basic computer block diagram.
Chapter 5 : Memory Management
Lecture 13 storage management
Table 12.1: Cash Flows to a Cash and Carry Trading Strategy.
PP Test Review Sections 6-1 to 6-6
Bright Futures Guidelines Priorities and Screening Tables
Project 5: Virtual Memory
EIS Bridge Tool and Staging Tables September 1, 2009 Instructor: Way Poteat Slide: 1.
Chapter 9: Virtual Memory
Module 10: Virtual Memory
Chapter 3 Memory Management
Chapter 10: Virtual Memory
Virtual Memory II Chapter 8.
Memory Management.
Bellwork Do the following problem on a ½ sheet of paper and turn in.
Operating Systems Operating Systems - Winter 2011 Dr. Melanie Rieback Design and Implementation.
Operating Systems Operating Systems - Winter 2012 Dr. Melanie Rieback Design and Implementation.
Operating Systems Operating Systems - Winter 2012 Chapter 4 – Memory Management Vrije Universiteit Amsterdam.
Operating Systems Operating Systems - Winter 2010 Chapter 3 – Input/Output Vrije Universiteit Amsterdam.
Exarte Bezoek aan de Mediacampus Bachelor in de grafische en digitale media April 2014.
Chapter 6 File Systems 6.1 Files 6.2 Directories
Sample Service Screenshots Enterprise Cloud Service 11.3.
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
1 RA III - Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Buenos Aires, Argentina, 25 – 27 October 2006 Status of observing programmes in RA.
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
Adding Up In Chunks.
1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt Synthetic.
Analyzing Genes and Genomes
SE-292 High Performance Computing
Essential Cell Biology
Clock will move after 1 minute
Intracellular Compartments and Transport
PSSA Preparation.
Essential Cell Biology
计算机系 信息处理实验室 Lecture 3 System Mechanisms (1)
Immunobiology: The Immune System in Health & Disease Sixth Edition
Physics for Scientists & Engineers, 3rd Edition
Energy Generation in Mitochondria and Chlorplasts
Murach’s OS/390 and z/OS JCLChapter 16, Slide 1 © 2002, Mike Murach & Associates, Inc.
计算机系 信息处理实验室 Lecture 10 Memory Management(2)
计算机系 信息处理实验室 Lecture 5 Startup and Shutdown
计算机系 信息处理实验室 Leture1 concepts and tools 2005 Spring 陈香兰.
计算机系 信息处理实验室 Lecture 14 Cache Manager
计算机系 信息处理实验室 Lecture 12 I/O System
Windows 2000 Memory Management Computing Department, Lancaster University, UK.
计算机系 信息处理实验室 Lecture 7 Processes, Threads, and Jobs (1)
Brown Bag Seminar FALL 2006 MEMORY MANAGEMENT
Presentation transcript:

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

计算机系 信息处理实验室 the Inside of Windows Two primary tasks Virtual memory  physical memory Paging How 2K implements virtual memory? How it manages the working set?

计算机系 信息处理实验室 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 Windows2000 4

计算机系 信息处理实验室 the Inside of Windows Memory Manager In Ntoskrnl.exe No parts of the memory manager exist in the HAL The memory manager is Fully reentrant

计算机系 信息处理实验室 the Inside of Windows Memory Manager Components Components: A set of executive system services A translation-not-valid and access fault trap handler Several key components that run in the context of six different kernel-mode system threads

计算机系 信息处理实验室 the Inside of Windows Six system threads 1.Working set manager (priority 16) Called by the balance set manager Once per second When free memory falls below a certain threshold Drives the overall memory management policies Working set trimming Aging Modified page writing

计算机系 信息处理实验室 the Inside of Windows Six system threads 2.Process/stack swapper (priority 23) In and out Awakened by the balance set manager and the thread-scheduling code in the kernel When an inswap or outswap operation needs to take place

计算机系 信息处理实验室 the Inside of Windows Six system threads 3.Modified page writer (priority 17) Writes dirty pages on the modified list back to the appropriate paging files Awakened when the size of the modified list needs to be reduced

计算机系 信息处理实验室 the Inside of Windows Six system threads 4.Mapped page writer (priority 17) Writes dirty pages in mapped files to disk Awakened when the size of the modified list needs to be reduced or If pages for mapped files have been on the modified list for more than 5 minutes.

计算机系 信息处理实验室 the Inside of Windows Six system threads 5.Dereference segment thread (priority 18) Responsible for system cache and page file growth and shrinkage. 6.Zero page thread (priority 0)

计算机系 信息处理实验室 the Inside of Windows Configuring the Memory Manager HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management ClearPageFileAtShutdown DisablePagingExecutive IoPageLockLimit LargePageMinimum LargeSystemCache NonPagedPoolQuota NonPagedPoolSize PagedPoolQuota PagedPoolSize SystemPages

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

计算机系 信息处理实验室 the Inside of Windows Determine System Memory Size Values Small: <19 MB Medium: MB Large: >32 MB if 2K Professional >64 MB if 2K Server Kernel-mode routines MmQuerySystemSize Small, medium, or large MmIsThisAnNtAsSystem TRUE for 2K Server; FALSE for 2K Professional

计算机系 信息处理实验室 the Inside of Windows Examining Memory Usage EXPERIMENT Viewing System Memory Information

计算机系 信息处理实验室 the Inside of Windows Pmon.exe (in the Windows 2000 Support Tools) Pstat.exe (in the Platform SDK)

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Accounting for Physical Memory Use

计算机系 信息处理实验室 the Inside of Windows System services The memory manager provides a set of system services to Allocate/free virtual memory Share memory between processes Map files into memory Flush virtual pages to disk Retrieve information about a range of virtual pages Change the protection of virtual pages Lock the virtual pages into memory

计算机系 信息处理实验室 the Inside of Windows Services exposed through Win32 API Page granularity virtual memory functions Virtualxxx Memory-mapped file functions CreateFileMapping, MapViewOfFile Heap functions Heapxxx the older interfaces Localxxx and Globalxxx

计算机系 信息处理实验室 the Inside of Windows Services provided by memory manager Allocating/deallocating physical memory Locking pages in physical memory for DMA transfers To Other kernel-mode components inside the executive Device drivers These functions begin with the prefix Mm Other, for example Ex…

计算机系 信息处理实验室 the Inside of Windows Services in detailed Reserving and Committing Pages Locking Memory Allocation Granularity Shared Memory and Mapped Files Protecting Memory Copy-on-Write Heap Functions Address Windowing Extensions

计算机系 信息处理实验室 the Inside of Windows Reserving and Committing Pages Reserved address space To reserve a range of virtual addresses for future use If accessed, an access violation will occur Committed pages either private and not shareable or mapped to a view of a section If accessed, ultimately translate to valid pages in physical memory. Win32 functions VirtualAlloc and VirtualAllocEx

计算机系 信息处理实验室 the Inside of Windows Locking Memory Pages can be locked in memory in two ways Using kernel-mode functions MmProbeAndLockPages, MmLockPagableCodeSection, MmLockPagableDataSection, or MmLockPagableSectionByHandle. Pages remain in memory until explicitly unlocked Using Win32 function VirtualLock Lock pages in the process working set. May paging

计算机系 信息处理实验室 the Inside of Windows Allocation Granularity Each region begins on an integral boundary System value: allocation granularity (e.g. 64KB) GetSystemInfo Not for kernel-mode code May be a single-page granularity The size of the region is n X (system page size)

计算机系 信息处理实验室 the Inside of Windows Shared Memory and Mapped Files To share memory among processes and the OS For example: Two processes share the same DLL Sharing mode Execute-only Copy-on-write

计算机系 信息处理实验室 the Inside of Windows Section objects File mapping objects (Win32 API) CreateFileMapping OpenFileMapping …

计算机系 信息处理实验室 the Inside of Windows Protecting Memory Kernel mode VS. user mode Each process: a separate private address space Hardware-controlled memory protection Read/write, read-only, … Standard ACLs for shared memory section objects 2K is a robust, reliable OS

计算机系 信息处理实验室 the Inside of Windows Copy-on-Write before after

计算机系 信息处理实验室 the Inside of Windows Heap Functions A heap A region of one or more pages of reserved address space that can be subdivided and allocated in smaller chunks by the heap manager. The heap manager A set of functions that can be used to allocate and deallocate variable amounts of memory The functions (in Ntdll.dll/Ntoskrnl.exe)

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

计算机系 信息处理实验室 the Inside of Windows System Memory Pools two types of dynamically sized memory pools Nonpaged pool Paged pool Look-Aside Lists Driver Verifier

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

计算机系 信息处理实验室 the Inside of Windows User Address Space Layout 0x0 ~ 0xFFFF64 KBNo-access region to aid programmers in avoiding incorrect pointer references 0x10000 ~ 0x7FFEFFFF2GB -192KBThe private process address space. 0x7FFDE000~0x7FFDEFFF4 KBTEB for first thread. 0x7FFDF000~0x7FFDFFFF4 KBPEB 0x7FFE0000~0x7FFE0FFF4 KBShared user data page 0x7FFE1000~0x7FFEFFFF60 KBNo-access region 0x7FFF0000~0x7FFFFFFF64 KBNo-access region that prevents threads from passing buffers that straddle the user/system space boundary

计算机系 信息处理实验室 the Inside of Windows System Address Space Layout

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

计算机系 信息处理实验室 the Inside of Windows Translating a Virtual Address Components of a 32-bit virtual address on x86 systems

计算机系 信息处理实验室 the Inside of Windows Translating a valid virtual address (x86-specific)

计算机系 信息处理实验室 the Inside of Windows Page Directories Each process has a single page directory The physical address of the process page directory is stored in the kernel process (KPROCESS) block but is also mapped virtually at address 0xC on x86 systems (0xC on systems running the PAE kernel image). All code running in kernel mode references virtual addresses, not physical ones CR3 on x86 systems page directory entries

计算机系 信息处理实验室 the Inside of Windows Process and System Page Tables page table system page table not all processes have the same view of system space page fault

计算机系 信息处理实验室 the Inside of Windows System & process-private page tables

计算机系 信息处理实验室 the Inside of Windows Page Table Entries

计算机系 信息处理实验室 the Inside of Windows Translation Look-Aside Buffer

计算机系 信息处理实验室 the Inside of Windows Physical Address Extension PAE allows access to up to 64 GB of physical memory The third level—page directory pointer table

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