I was wondering if it’s possible to detect and perform some action every time my code detects that a CPU context switch has occurred (as opposed to counting how many context switches occurred in a certain period of time). Anyway to do this in, say, C#?
Share
No, this is not possible to do in C#. Because C# is a managed language that runs code in a user mode. Context switch is originated from a kernel mode to which no access is possible from the user level code.
This might be possible with a C driver, however, the code may severely damage OS performance and stability.