I don't think macOS allows a userspace program to set thread affinities.
Not only are the functions commented out, there's this note
THREAD_AFFINITY_POLICY:
This policy is experimental.
This may be used to express affinity relationships
between threads in the task. Threads with the same affinity tag will
be scheduled to share an L2 cache if possible. That is, affinity tags
are a hint to the scheduler for thread placement.
The namespace of affinity tags is generally local to one task. However,
a child task created after the assignment of affinity tags by its parent
will share that namespace. In particular, a family of forked processes
may be created with a shared affinity namespace.
Here's one example of userspace programs assigning affinity to specific cores
> Use it to automatically run busy background apps on the M1 or M2's efficiency cores to save power, leaving the performance cores for the apps you want to run fastest.
You can in a way, if you tie up the E cores by pinning work to them exclusively, the scheduler will send other stuff to the P cores due to resource constraint avoidance attempts. It's not power efficient to sit and wait for an efficient core when you can buzz it through a P core super quick and get back to idle, I would imagine haha
Not only are the functions commented out, there's this note
https://github.com/apple-oss-distributions/xnu/blob/main/osf...