ychener
驱动牛犊
驱动牛犊
  • 注册日期2003-03-18
  • 最后登录2016-01-07
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望20点
  • 贡献值0点
  • 好评度19点
  • 原创分0分
  • 专家分0分
阅读:4869回复:13

关于ExAllocatePoolWithTag的问题

楼主#
更多 发布于:2003-03-25 22:39
最近在改微软的一个Ramdisk例子,文件格式已经搞定,可是居然ExAllocatePoolWithTag分配内存失败,不知道是什么原因?
我的机器可是有512M内存的,而且我只是分配了128M,怎么会分配不出来?? 大家有没有碰到这样的情况?
ychener
驱动牛犊
驱动牛犊
  • 注册日期2003-03-18
  • 最后登录2016-01-07
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望20点
  • 贡献值0点
  • 好评度19点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2003-03-25 22:41
忘记说了 用的类型是NonPagedPool
ychener
驱动牛犊
驱动牛犊
  • 注册日期2003-03-18
  • 最后登录2016-01-07
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望20点
  • 贡献值0点
  • 好评度19点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2003-03-25 23:00
有没有人知道呀!
arthurtu
驱动巨牛
驱动巨牛
  • 注册日期2001-11-08
  • 最后登录2020-12-19
  • 粉丝0
  • 关注0
  • 积分26分
  • 威望161点
  • 贡献值0点
  • 好评度35点
  • 原创分0分
  • 专家分0分
  • 社区居民
地板#
发布于:2003-03-25 23:16
分配128M的nonpagedpool?
xyyln
驱动老牛
驱动老牛
  • 注册日期2003-01-02
  • 最后登录2009-12-28
  • 粉丝0
  • 关注0
  • 积分4分
  • 威望11点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2003-03-26 09:36
non paged pool是比较稀有的资源吧,动不动就128M,老兄你太贪了
[img]http://www.jt99.com/zjbbs/UploadFile/2003113018513643830.gif[/img]
ychener
驱动牛犊
驱动牛犊
  • 注册日期2003-03-18
  • 最后登录2016-01-07
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望20点
  • 贡献值0点
  • 好评度19点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2003-03-26 10:02
问题一:我的机器是有512M内存的呀,为什么分配不出来?
问题二:即使我用了PagePool选项也分配不出140M内存,为啥?


我估计是不是内存中没有一整块这么大的内存,碎片比较多??

望高手给回答。。
SharpShooter
驱动小牛
驱动小牛
  • 注册日期2002-04-07
  • 最后登录2013-07-05
  • 粉丝0
  • 关注0
  • 积分5分
  • 威望40点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2003-03-26 16:43
问题一:我的机器是有512M内存的呀,为什么分配不出来?
问题二:即使我用了PagePool选项也分配不出140M内存,为啥?


我估计是不是内存中没有一整块这么大的内存,碎片比较多??

望高手给回答。。

这样,你把操作系统卸了,单独跑你的程序,估计512M内存都可以让你用了,呵呵。
写驱动不如买足彩!!
xyyln
驱动老牛
驱动老牛
  • 注册日期2003-01-02
  • 最后登录2009-12-28
  • 粉丝0
  • 关注0
  • 积分4分
  • 威望11点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
7楼#
发布于:2003-03-27 16:56
    今天比较空,来帮你的贴子收尾吧。
    即使是在512M内存的机器上,不管分页还是非分页内存,都不能获得你想象的那么多空间,原因如下:
    1、你的驱动有机会分配内存时,系统的其它部分已经使用了相当数量的非分页内存,从系统保障的角度来看你也不可能获得剩下的所有内存;
    2、系统运行了一段时间后,虚拟地址空间已经不完整,分成了很多小的碎片,堆管理器也找不到一个非常大的空间了。
    事实上,一次ExAllocatePoolWithTag最多分配129M的分页内存和100M的非分页内存。
[img]http://www.jt99.com/zjbbs/UploadFile/2003113018513643830.gif[/img]
ychener
驱动牛犊
驱动牛犊
  • 注册日期2003-03-18
  • 最后登录2016-01-07
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望20点
  • 贡献值0点
  • 好评度19点
  • 原创分0分
  • 专家分0分
8楼#
发布于:2003-03-28 09:36
那就是说,如果我要写一个Ramdisk驱动程序,如果想分配大于128M内存的驱动盘,那么我至少需要自己定一个内存的数据结构,在逻辑上保证是连续的,但是在物理内存上是不连续的,才能满足我的需求了,那不是又要改程序了。而且驱动开发动不动就蓝屏死机,非常郁闷。进展很慢。
ychener
驱动牛犊
驱动牛犊
  • 注册日期2003-03-18
  • 最后登录2016-01-07
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望20点
  • 贡献值0点
  • 好评度19点
  • 原创分0分
  • 专家分0分
9楼#
发布于:2003-03-28 19:23
终于找到关于ExAllocatePool的详细说法了。
在微软的网站上详细的说明:Q126402




PagedPoolSize and NonPagedPoolSize Values in Windows NT

--------------------------------------------------------------------------------
The information in this article applies to:
Microsoft Windows NT Workstation versions 3.5, 3.51, 4.0
Microsoft Windows NT Server versions 3.5, 3.51, 4.0

--------------------------------------------------------------------------------

SUMMARY
Windows NT calculates NonPagedPoolSize and PagedPoolSize based on the amount of physical memory present in the computer at boot time. This article describes the algorithms used to calculate these values on an x86- based computer.
NOTE: The Windows NT 3.5 Resource kit incorrectly describes PagedPoolSize calculations.

MORE INFORMATION
NonPagedPoolSize and PagedPoolSize are calculated using complex algorithms based on physical memory size. However, you can use the following formulas to approximate these values for an X86-based computer.
  
Definitions
MinimumNonPagedPoolSize = 256K
MinAdditionNonPagedPoolPerMb = 32K
DefaultMaximumNonPagedPool = 1 MB
MaxAdditionNonPagedPoolPerMb = 400K
PTE_PER_PAGE = 1024
PAGE_SIZE=4096
  
NonPagedPoolSize Calculation
NonPagedPoolSize = MinimumNonPagedPoolSize + ((Physical MB - 4) * MinAdditionNonPagedPoolPerMB)
EXAMPLE - On a 32 MB x86-based computer:

MinimumNonPagedPoolSize = 256K
NonPagedPoolSize = 256K + ((32 - 4) * 32K) = 1.2 MB

MaximumNonPagedPoolSize = DefaultMaximumNonPagedPool + ((Physical MB - 4) * MaxAdditionNonPagedPoolPerMB)

If MaximumNonPagedPoolSize < (NonPagedPoolSize + PAGE_SIZE * 16),
then MaximumNonPagedPoolSize = (NonPagedPoolSize + PAGE_SIZE * 16)

IF MaximumNonPagedPoolSize >= 128 MB MaximumNonPagedPoolSize = 128 MB

EXAMPLE - On a 32 MB x86-based computer:

MaximumNonPagedPoolSize = 1 MB + ((32 - 4) * 400K) = 12.5 MB
  

PagedPoolSize Calculation
Size = (2 * MaximumNonPagedPoolSize) / PAGESIZE Size = (Size + (PTE_PER_PAGE - 1)) / PTE_PER_PAGE PagedPoolSize = Size * PAGESIZE * PTE_PER_PAGE IF PagedPoolSize >= 192 MB PagePoolSize = 192 MB EXAMPLE - On a 32 MB x86-based computer:
Size = (2 * 12.5M) / 4096 = 6400
Size = (6400 + (1024 - 1)) / 1024 = 7.25
PagedPoolSize = 7.25 * 4096 * 1024 = 30MB
NOTE: If both values are set to zero in the registry, PagedPoolSize will calculate to approximately memory size)
The kernel debugger can be used to view these global variables in memory.
The values shown below are for a 32 MB x86-based computer running Windows NT 3.5, build 807:

kd> dd MmDefaultMaximumNonPagedPool
8019e4d4 00100000 (1Mbyte)

kd> dd MmSizeOfNonPagedPoolInBytes
80196188 00120000 (1,179,648)

kd> dd MmMinimumNonPagedPoolSize l1
8019e4cc 00040000 (262144)

kd> dd MmNumberOfPhysicalPages l1
801961ac 00002010 (8208)

kd> dd MmMinAdditionNonPagedPoolPerMb l1
8019e4d0 00008000 (32768)

kd> dd MmMaximumNonPagedPoolInBytes l1
80196310 00c20000 (12713984)

kd> dd MmSizeOfPagedPoolInBytes l1
8019e4dc 02000000 (33554432)

These values may be modified in the registry.

WARNING: Using the Registry Editor incorrectly can cause serious, system- wide problems that may require you to reinstall Windows NT to correct them. Microsoft cannot guarantee that any problems resulting from the use of the Registry Editor can be solved. Use this tool at your own risk.

The page pooled memory management parameters are located in:
  

   HKEY_LOCAL_MACHINE
     \\SYSTEM
       \\CurrentControlSet
         \\Control
           \\Session Managerl
             \\Memory Management
For additional information about the /3GB setting, click the article number below to view the article in the Microsoft Knowledge Base:
Q171793 Information on Application Use of 4GT RAM Tuning
Microsoft Windows 2000
The Windows 2000 memory model increases the amount of nonpaged pool and paged pool memory available to the system.
A Windows 2000-based 32-bit x86 computer that is booted without the /3GB switch is changed to a maximum paged pool of approximately 300-470 MB (from 192 MB in Windows NT 4.0).

With Windows 2000, the amount of nonpaged pool that the operating system can use is increased to 256 MB (from 128 MB in Windows NT 4.0).

If the server is booted with the /3GB switch enabled, the memory model remains that same for nonpaged and paged pool as in Windows NT 4.0.

Additional query words: server storage poolcalc pool non-paged
Keywords          : kbnetwork ntnetserv NTSrvWkst
Version           : winnt:3.5,3.51,4.0
Platform          : winnt
Issue type        :
arthurtu
驱动巨牛
驱动巨牛
  • 注册日期2001-11-08
  • 最后登录2020-12-19
  • 粉丝0
  • 关注0
  • 积分26分
  • 威望161点
  • 贡献值0点
  • 好评度35点
  • 原创分0分
  • 专家分0分
  • 社区居民
10楼#
发布于:2003-03-28 20:20
在inside windows2000有讲。

You can override the initial size of these pools by changing the values NonPagedPoolSize and PagedPoolSize in the registry key HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management from 0 (which causes the system to compute the size) to the size desired in bytes. You can\'t, however, go beyond the maximum pool sizes listed in Table 7-4.
Table 7-4 Maximum Pool Sizes

Pool Type Maximum Size
Nonpaged 256 MB (128 MB if booted /3GB)
Paged 491.875 MB

第7章

xyyln
驱动老牛
驱动老牛
  • 注册日期2003-01-02
  • 最后登录2009-12-28
  • 粉丝0
  • 关注0
  • 积分4分
  • 威望11点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
11楼#
发布于:2003-03-29 22:49
理想和现实的差距
[img]http://www.jt99.com/zjbbs/UploadFile/2003113018513643830.gif[/img]
ychener
驱动牛犊
驱动牛犊
  • 注册日期2003-03-18
  • 最后登录2016-01-07
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望20点
  • 贡献值0点
  • 好评度19点
  • 原创分0分
  • 专家分0分
12楼#
发布于:2003-03-30 16:58
请问我如果给分,贴子收尾
arthurtu
驱动巨牛
驱动巨牛
  • 注册日期2001-11-08
  • 最后登录2020-12-19
  • 粉丝0
  • 关注0
  • 积分26分
  • 威望161点
  • 贡献值0点
  • 好评度35点
  • 原创分0分
  • 专家分0分
  • 社区居民
13楼#
发布于:2003-03-30 17:43
请问我如果给分,贴子收尾

第一贴有个“给分”按钮。
游客

返回顶部