core_affinity_rs icon indicating copy to clipboard operation
core_affinity_rs copied to clipboard

Is it possible to get core id in which a thread is running?

Open xiaoniu-578fa6bff964d005 opened this issue 5 years ago • 2 comments

It seems we can implement it on linux with sched_getcpu. This link gives another way to get cpu id on x86 platform, which can cover windows on x86.

Current implementation for linux and windows can be found at repo. I don't have any idea on how to implement on Mac, nor do I have a device for testing. Maybe we can reference to this answer.

Current implementation of windows use GetCurrentProcessorNumber API. Seems it is not applicable for more than 64 logical processors.