I'm looking for a function on Mac OS and BSD that's equivalent to Linux's sched_getcpu()
, and Windows' GetCurrentProcessorNumberEx()
in order to implement a library for cpu-local storage. It's clearly possible to emulate this with the cpuid or rdtscp instructions, but it's possible to do better with kernel cooperation: https://lkml.org/lkml/2007/1/6/190.
I already know that the thread's current CPU may change by the time I use the information.