锁定内存如何不分页? vs Unix mlock。 [英] How lock memory so not paged? vs Unix mlock.

查看:70
本文介绍了锁定内存如何不分页? vs Unix mlock。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Windows XP和Unix上运行的时间关键型应用程序。我已经得到了一些时间问题,我已经追踪到虚拟内存被分页并且

out了。如果我能锁定,我想我可以解决问题。一个巨大的内存

缓冲到物理内存中,因此它不会被分页输入。我的其余部分的b $ b程序(代码和其他数据)可以被分页和out:只有这一个

缓冲区是至关重要的。


Unix(至少有些Unix)有一个运行良好的mlock()函数

对我来说。现在我喜欢在Windows上做同样的事情。


问题:Windows XP中是否存在一种技术(我使用Visual C ++)来锁定

a内存缓冲区(我的程序用malloc()分配到物理

内存所以它永远不会被分页?


提前感谢任何回复,
neal

Ive got a time-critical application that runs on Windows XP and Unix. I''ve
got some timing issues that Ive traced to virtual memory getting paged in and
out. I think I can solve the problem if I can "lock" a certain huge memory
buffer into physical memory, so it is not paged out and in. The rest of my
program (code and other data) can get paged in and out: it is just this one
buffer that is critical.

Unix (some Unixs, at least) have an mlock() function that is working well
for me. Now Id like to do the same thing on Windows.

Question: Is there a technique in Windows XP (Im using Visual C++) to lock
a memory buffer (that my program allocated with malloc() ) into physical
memory so it is never paged out?

Thanks in advance for any replies,
neal

推荐答案

我做了一些狩猎,发现了这个功能

VirtualLock()

可以满足我在Windows中的要求。


如果有人对VirtualLock()有任何建议或提示,我很感激。


谢谢,

neal


" noleander"写道:
I''ve done some hunting around and found the function
VirtualLock()
that may meet my requriements in Windows.

If anyone has any advice or tips about VirtualLock(), Id appreciate it.

Thanks,
neal

"noleander" wrote:
我有一个在Windows XP和Unix上运行的时间关键型应用程序。我已经找到了一些时间问题,我已经追踪到虚拟内存被打开并且
了。如果我能锁定,我想我可以解决问题。一个巨大的内存缓冲到物理内存中,因此它不会被分页输入。我的其余程序(代码和其他数据)可以被分页输入和输出:它只是这一个
缓冲区至关重要。

Unix(至少有些Unix)有一个运行良好的mlock()函数对我来说很好。现在我喜欢在Windows上做同样的事情。

问题:Windows XP中是否有一种技术(我使用Visual C ++)锁定内存缓冲区(我的程序用malloc分配) ())进入物理内存所以它永远不会被分页?

提前感谢任何回复,
neal
Ive got a time-critical application that runs on Windows XP and Unix. I''ve
got some timing issues that Ive traced to virtual memory getting paged in and
out. I think I can solve the problem if I can "lock" a certain huge memory
buffer into physical memory, so it is not paged out and in. The rest of my
program (code and other data) can get paged in and out: it is just this one
buffer that is critical.

Unix (some Unixs, at least) have an mlock() function that is working well
for me. Now Id like to do the same thing on Windows.

Question: Is there a technique in Windows XP (Im using Visual C++) to lock
a memory buffer (that my program allocated with malloc() ) into physical
memory so it is never paged out?

Thanks in advance for any replies,
neal



你好noleander!
Hi noleander!
问题:Windows XP中是否有一种技术(我使用Visual C ++)来锁定内存缓冲区(我的程序分配了)使用malloc())进入物理内存所以它永远不会被分页?
Question: Is there a technique in Windows XP (Im using Visual C++) to lock
a memory buffer (that my program allocated with malloc() ) into physical
memory so it is never paged out?




请参阅:VirtualLock
http://msdn.microsoft.com/library/en...irtuallock。 asp


不建议这样做,但对于特殊应用/ PC它

可能会有所作为...


-

问候

Jochen


我关于Win32和.NET的博客
http://blog.kalmbachnet.de/


" noleander" <无******* @ discussions.microsoft.com>在消息中写道

news:72 ********************************** @ microsof t.com ...
"noleander" <no*******@discussions.microsoft.com> wrote in message
news:72**********************************@microsof t.com...
我已经做了一些狩猎,并找到了可能符合我在Windows中的要求的功能
VirtualLock()
<如果有人对VirtualLock()有任何建议或提示,我很感激。
I''ve done some hunting around and found the function
VirtualLock()
that may meet my requriements in Windows.

If anyone has any advice or tips about VirtualLock(), Id appreciate it.




我不知道mlock是如何工作的所以我不是知道它是否会做你想要的

确切。


但是,要明确该功能将一定数量的页面锁定到工作
set"调用过程。 (工作集是由物理内存支持的页面集合

)。在内存压力下Windows是免费的

交换你的过程为更紧迫的东西腾出空间,锁定

页面包括。


问候,




I wouldn''t know how mlock works so I don''t know if it will do what you want
exactly.

But, to be clear the function locks some number of pages into the "working
set" of the calling process. (The working set is the collection of pages
that are backed by physical memory). Under memory pressure Windows is free
to swap out your process to make room for something more pressing, locked
pages included.

Regards,
Will


这篇关于锁定内存如何不分页? vs Unix mlock。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆