大佬教程收集整理的这篇文章主要介绍了如何在boost(c)中将内存页锁定到物理RAM?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这样的事情(假设GetPageSize和Align *已经实现):
void LockMemory(void* addr,size_t len) { #if Defined(_unix_) const size_t pageSize = GetPageSize(); if (mlock(AlignDown(addr,pageSizE),AlignUp(len,pageSizE))) throw std::exception(LastSystemErrorText()); #elif Defined(_win_) HANDLE hndl = GetCurrentProcess(); size_t min,max; if (!GetProcessWorkingSetSize(hndl,&min,&maX)) throw std::exception(LastSystemErrorText()); if (!SetProcessWorkingSetSize(hndl,min + len,max + len)) throw std::exception(LastSystemErrorText()); if (!VirtualLock(addr,len)) throw std::exception(LastSystemErrorText()); #endif }
我们还试图使用一些boost :: libraries,但是他们厌倦了修复跨平台问题并转而使用我们自己的实现.它写得慢,但它有效.
以上是大佬教程为你收集整理的如何在boost(c)中将内存页锁定到物理RAM?全部内容,希望文章能够帮你解决如何在boost(c)中将内存页锁定到物理RAM?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。