简体   繁体   English

如何关闭windows中缓存的预取?

[英]How to close the prefetch of cache in windows?

在C / C ++程序中,如何关闭Windows系统中每个核心的预取?

There is a Windows API call FlushInstructionCache() 有一个Windows API调用FlushInstructionCache()

Perhaps this is what you need? 也许这就是你需要的? It is typically used by self modifying code to make sure changes to code in the RAM are visible to the processor. 它通常由自修改代码使用,以确保处理器可以看到RAM中代码的更改。

I have seen this trick mentioned in some code, although I am not 100% sure if this trick is what you're looking for, however, the code was this 我已经看到了一些代码中提到的这个技巧,虽然我不是100%确定这个技巧是否是你想要的,但是,代码是这个

Sleep(0);

By using Sleep(0) , you are clearing the CPU instructions and cause a context switch... Now you did say 'for each core', I do not think you can explicitly select a core to do that as how do you know which core is running the code that is need of a closing the pre-fetching of the cache.... 通过使用Sleep(0) ,您正在清除CPU指令并导致上下文切换......现在您确实说'对于每个核',我认为您不能明确选择核心来执行此操作,因为您如何知道核心正在运行需要关闭预取缓存的代码....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM