In Linux there is a sched_setaffinity() function defined in sched.h, but I can't seem to find anything like that in Mac OS X 10.6 pthreads implementation... If it is not possible to set affinity, what is the default policy in OS X?
Asked
Active
Viewed 6,998 times
1 Answers
5
Mac OS X has Thread Affinity API and you can use it with pthread ID as thread_policy_set(pthread_mach_thread_np(pthreadId), but, as far as I know, there are no APIs like sched_setaffinity.

paddy
- 60,864
- 6
- 61
- 103

Kazuki Sakamoto
- 13,929
- 2
- 34
- 96
-
1What the hell? I took a look at Mac OS X 10.6 SDK's /usr/include/mach/thread_policy.h and found out that the thread_policy_set() / thread_policy_get() functions are commented out! What is the meaning of this?! – Ryan May 31 '11 at 08:01
-
It is really compatible with pthread. Please take a look at /Developer/Extras/CoreAudio/PublicUtility/CAPThread.cpp or google "thread_policy_set pthread_mach_thread_np". And thread_policy_set/thread_policy_get are in /Developer/SDKs/MacOSX10.6.sdk/usr/include/mach/x86_64/thread_act.h . Anyway, these API are not same as sched_setaffinity. – Kazuki Sakamoto May 31 '11 at 11:28