On Solaris, processor_bind
is used to set affinity for threads. You need to know the LWPID of the target thread or use the constant P_MYID
to refer to yourself.
I have a function that looks like this:
void set_affinity(pthread_t thr, int cpu_number)
{
id_t lwpid = what_do_I_call_here(thr);
processor_bind(P_LWPID, lwpid, cpu_number, NULL);
}
In reality my function has a bunch of cross platform stuff in it that I've elided for clarity.
The key point is that I'd like to set the affinity of an arbitrary pthread_t so I can't use P_MYID
.
How can I achieve this using processor_bind
or an alternative interface?