开发者

Is it possible to check if a cache line is invalid and/or a way to manually revalidate a cache line?

(I'm primarily interested in x86 architectures, but would be interested to hear if there's a way to do this in other architectures also)

Is there any way to programmatically check the state of a cache line containing a certain memory address? I don't want to read the开发者_如何学运维 contents of that address, and don't want the penalty of reading from main memory incurred from a cache miss, I just want to check the state of the cache line.

And is there any way to programmatically revalidate an invalid cache line without writing through to memory? (well, I guess with MESI, by "revalidate" I mean change its state to "Modified")


The only thing I can think of is to use the PREFETCH optimization hint. So, instead of:

mov eax, (DWORD PTR [esi])

You would do:

prefetch [esi]
;
; give processor time to load cacheline...
;
mov eax, (DWORD PTR [esi])

Fundamentally I think what you're trying to do is flawed. If you were running on a custom single-tasking operating system it might work, but on today's modern multi-tasking systems it's simply impossible to control the processor like that.


Cache is completely invisible to programmer. Programmer works with virtual addresses while cache work with physical addresses.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜