分页池内存还是非分页池内存? (Windows驱动开发)
我是Windows驱动程序开发的新手。 我只是想知道,驱动程序中的全局变量将使用分页池内存还是非分页池内存?
感谢和问候
纳瓦内斯
I am newbie in windows driver development. I just want to know , a global variable in a driver will use paged pool memory or non paged pool memory ?
Thanks and Regards
Navaneeth
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
依靠。 非分页池应保留用于必须保留在 RAM 中的内存,因此,如果您正在执行一些会受到磁盘操作中的内存页影响的关键操作,则应使用非分页池。
有关详细信息,请参阅此处。
看看 this (尽管它讨论的是 c++ 而不是 C)似乎默认情况下全局变量可以通过 #pragma 位于其中之一。 另外,在 this 的第 22 页上,我们了解了如何执行此操作。 最后此讨论在这里我们看到数据段默认情况下应该是不可分页的。
Depends. The Non paged pool should be reserved for memory that must stay in RAM so if you are doing something critical that would affected by a memory page from disk operation then use non paged.
See here for more info.
Looking at this (though it discusses c++ as opposed to C) it would seem that by default the globals can be located in either by #pragma. Also on p22 of this we see how to do this. Finally this discuss here we see that the data segment should be non pagagable by default.
内核模式驱动程序中的全局变量是从 NonPagedPool 分配的。
您还可以使用设备扩展(当您调用 IoCreateDevice 时),它始终从 NonPaged 内存中分配。
我希望这有帮助,
马丁
Global variables in a kernel mode driver are allocated from NonPagedPool.
You can also use the device extension (when you call IoCreateDevice), it is always allocated from NonPaged memory.
I hope this helps,
Martin
我发现的另一个很好的答案是:“非分页池是内核内存,当 Windows 耗尽可用物理内存时,它无法被分页到页面文件中。驱动程序使用它来分配它们需要的内存。” 来自此处
Another good answer that I find is: "Nonpaged pool is kernel memory which can't be paged out into the pagefile when Windows runs out of free physical memory. It is used by drivers to allocate memory which they need." from here