How to find the processor my stream is running in C #?

How to find the processor my stream is running in C #?

+4
source share
3 answers

This is not necessarily constant - the thread can be scheduled on different cores throughout life. You can set proximity masks to bind a specific thread to a specific processor if you want. Further information on what can be done in .NET can be found in the API documents for Thread.BeginThreadAffinity .

+4
source

IMHO it is possible that the .NET thread is not associated with any of its own threads. > NET runtime can move .NET threads between different threads and processors at any time.

+1
source

I'm not sure you can. You can get the process merge mask (GetProcessAffinityMask) and set it (SetProcessAffinityMask). You can also set the thread merge mask, but I understand that in doing so you restrict the thread to work on one of the processors on which your affine mask is installed.

If you delve into specific threads running on specific cores, you probably want to set a process affinity mask to determine the set of cores your code can run on, and threads in your process will then float among the selected cores.

+1
source

Source: https://habr.com/ru/post/1302466/


All Articles