Nonpaged Pool(非分页池) 和 Paged Pool(分页池) 在Windows中的用处

简介: 很多DBA对nonpage pool 和 paged pool 搞不太清楚干嘛用的,看perfmon中的说明也看得稀里糊涂。找到一个资料就翻译一下。 From:http://blogs.technet.

很多DBA对nonpage pool 和 paged pool 搞不太清楚干嘛用的,看perfmon中的说明也看得稀里糊涂。找到一个资料就翻译一下。

From:http://blogs.technet.com/b/markrussinovich/archive/2009/03/26/3211216.aspx

Nonpaged Pool(非分页池)

The kernel and device drivers use nonpaged pool to store data that might be accessed when the system can’t handle page faults. The kernel enters such a state when it executes interrupt service routines (ISRs) and deferred procedure calls (DPCs), which are functions related to hardware interrupts. Page faults are also illegal when the kernel or a device driver acquires a spin lock, which, because they are the only type of lock that can be used within ISRs and DPCs, must be used to protect data structures that are accessed from within ISRs or DPCs and either other ISRs or DPCs or code executing on kernel threads. Failure by a driver to honor these rules results in the most common crash code, IRQL_NOT_LESS_OR_EQUAL.

内核或者设备驱动使用非分页池来保存可能访问的数据,但是在访问的时候又不能出现也错误。当内核执行中断服务程序并且延迟调用过程的时候就会进入这种状态,这个状态和硬件中断相关联。当内核或者设备驱动在这个状态后,获取了一个自旋锁,页错误也是不被允许的,自旋锁是唯一能在延迟调用或者中断服务程序中能用的锁类型,用来保护被延迟过程调用和中断服务程序访问的数据,可能来自于延迟过程调用和中断服务程序,也可能来自其他的延迟过程调用和中断服务程序,或者其他的内核线程。如果驱动程序在执行整个规则的时候出错会得到一个 IRQL_NOT_LESS_OR_EQUAL 的崩溃代码

Nonpaged pool is therefore always kept present in physical memory and nonpaged pool virtual memory is assigned physical memory. Common system data structures stored in nonpaged pool include the kernel and objects that represent processes and threads, synchronization objects like mutexes, semaphores and events, references to files, which are represented as file objects, and I/O request packets (IRPs), which represent I/O operations.

非分页池因此总是报错在内存中,非分页池的虚拟地址被物理地址分配。通用的系统数据结构被保存在非分页池中包含内核和代表进程和线程的对象,互斥对象,同步信号量,引用文件(代表文件对象),和I/O请求包(代表I/O操作)

Paged Pool(分页池)

Paged pool, on the other hand, gets its name from the fact that Windows can write the data it stores to the paging file, allowing the physical memory it occupies to be repurposed. Just as for user-mode virtual memory, when a driver or the system references paged pool memory that’s in the paging file, an operation called a page fault occurs, and the memory manager reads the data back into physical memory. The largest consumer of paged pool, at least on Windows Vista and later, is typically the Registry, since references to registry keys and other registry data structures are stored in paged pool. The data structures that represent memory mapped files, called sections internally, are also stored in paged pool.

分页池,从字面意思来说,也就是可以存到系统的分页文件中,允许物理内存重定向。如用户模式的虚拟内存,当驱动或者系统引用分页池内存在分页文件中,那么一个操作就会调用页错误,内存管理系统把数据从分页文件中读取到物理内存。在windows vista和之后的版本,分页池最大的使用者是注册表,引用的注册键值和其他注册表数据都是存储在分页池中。内存映射文件(内部叫做内存对象[Sections])也存在分页池中。

 

Device drivers use the ExAllocatePoolWithTag API to allocate nonpaged and paged pool, specifying the type of pool desired as one of the parameters. Another parameter is a 4-byte Tag, which drivers are supposed to use to uniquely identify the memory they allocate, and that can be a useful key for tracking down drivers that leak pool, as I’ll show later.

设备驱动可以使用ExAllocatePoolWithTag API来申请非分页池和分页池,可以使用参数来指定在那个类型的池中申请。另外一个参数是4个字节的tag,用来唯一标示分配内存的驱动程序,并且在跟踪驱动程序是否缺少池十分有用。

目录
相关文章
|
9月前
|
Linux
pmdk如何在线动态扩展pool大小
pmdk如何在线动态扩展pool大小
64 0
|
10月前
|
存储 SQL 缓存
细说MySQL中磁盘与CPU的交互——神秘的Buffer Pool
MySQL是如何读取记录的?Buffer Pool缓存功不可没!什么是Buffer Pool?它的结构是什么样的?当数据不断的读取,缓存的数据如何更新?本文将带你详细了解这些!
74 0
细说MySQL中磁盘与CPU的交互——神秘的Buffer Pool
|
缓存 安全 Java
GoFrame gpool 对象复用池 | 对比sync.pool
要介绍gpool对象复用池之前,大家有必要先了解一下go原生提供的sync.pool。
179 0
|
.NET C#
C#中“.NET技术”字符串的内存分配与驻留池
  刚开始学习C#的时候,就听说CLR对于String类有一种特别的内存管理机制:有时候,明明声明了两个String类的对象,但是他们偏偏却指向同一个实例。如下: String s1 = "Hello";String s2 = "Hello"; //s...
832 0
|
.NET C#
一起谈.NET技术,C#中字符串的内存分配与驻留池
  刚开始学习C#的时候,就听说CLR对于String类有一种特别的内存管理机制:有时候,明明声明了两个String类的对象,但是他们偏偏却指向同一个实例。如下: String s1 = "Hello";String s2 = "Hello"; //s...
736 0