Is access to CPU cache accessible (read and write) through C #?

I want to know if there are objects in C # that allow access to the CPU cache. This is just interesting for me, but I have nothing to do with the processor cache at the moment. Therefore, I was wondering if this is limited access to the system or whether it is also accessible to users. I'm talking about L1 / L2 or what they are called!

It would be nice to hear your comments, external links, and possibly some code snippets! Thanks.

+4
source share
3 answers

The programming language does not have direct access to the CPU cache. Reading and writing a cache is something that is done automatically by hardware; There is no way to write instructions that relate to the cache as any kind of separate object. Reading and writing to the cache occurs as a side effect for all instructions that relate to memory.

+10
source

C # is too high for this activity. If you do not call any other library written in C / ASM =) Of course, working with the cache as a whole is a rather obscure topic, and for the most part it is completely controlled by hardware. On the other hand, there are some pretty interesting questions / discussions about SO that you may have already met.

Programming with C ++ Cache

How to make processor cache in Windows x86?

In any case, despite the limitations, you can still predict (somewhat) what the cache will do and use it for special applications.

+4
source
public static string GetComponent(string hwclass, string syntax) { var mos = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM " + hwclass); foreach (var o in mos.Get()) { var mj = (ManagementObject)o; CpuModel = Convert.ToString(mj[syntax]); } return CpuModel; } private string L2CacheSize = HardwareManagement.GetComponent("Win32_Processor", "L2CacheSize"); private string L3CacheSize = HardwareManagement.GetComponent("Win32_Processor", "L3CacheSize"); 
0
source

All Articles