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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With