Hello,
I am trying to set the thread affinity in a little project of mine and I am a little confuse. I don't think that's possible to link a thread with a specific core with Mac OS X, which really surprise me. It seems that you can only give int to the os to sort your thread, but does it mean the thread will be executed on the same core for all the application execution?
To test, I've wrote a simple program to validate and it seems impossible to print from which core the thread is executing. For example, on linux, you can use sched_getcpu() function to get the cpu id.
To set the affinity on my thread, I did something like that:
thread_affinity_policy_data_t policy = { m_affinityMask };
thread_policy_set(pthread_mach_thread_np(m_thread.native_handle()), THREAD_AFFINITY_POLICY, (thread_policy_t)&policy, 1);
In this case, I imaginge the term affinity mask is wrong since it's more like an abstract tag. Can you give me advice on this?
Thanks!