Thread Affinity

Hello :) I am working with threads and I need to assign each thread to a specific core. Doing some research I came to the conclusion that I cannot do this using the <thread> library. So is it possible that someone can provide an example of how this is done using SetThreadAffinityMask() function?I am not sure how to use it so if anyone can give me a hint it will be really appreciated :)
Wait what?
Why would you need to assign Threads to specific cores?

SetThreadAffinityMask() is a windows-only solution and this is the General C++ Programming forum so I'll give you an other solution.

You can get the native handle for std::threads by calling native_handle(); and then use the pthread function pthread_setaffinity_np

(see: http://stackoverflow.com/questions/16034448/obtaining-thread-core-affinity-in-c-11-through-pthreads)
Last edited on
Ty for the hint :)
Topic archived. No new replies allowed.