Reputation: 5692
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.
Upvotes: 5
Views: 1654
Reputation: 24617
There are one or two questions which cover queue tracking for OSX, as well as a dispatch_get_global_queue wiki page which covers the equivalent for BSD. I don't know if you can map a queue to a CPU, but if so, that would seem to be the closest equivalent.
Upvotes: 2