pthread_setrunon_np(3P)pthread_setrunon_np(3P)NAME
pthread_setrunon_np, pthread_getrunon_np - thread CPU scheduling affinity
C SYNOPSIS
#include <pthread.h>
int pthread_setrunon_np(int cpu);
int pthread_getrunon_np(int *cur_cpu);
DESCRIPTION
Executing threads run on the most eligible CPU determined by the kernel.
This choice may be changed for threads with the PTHREAD_SCOPE_SYSTEM or
PTHREAD_SCOPE_BOUND_NP attribute using the pthread_setrunon_np()
interface. This interface requests that the calling thread execute
exclusively on the named cpu. The CPU should be chosen in the same way
as for sysmp(2) interface with the MP_MUSTRUN command. Consult the
sysmp(2) man page section on MP_MUSTRUN for additional information
concerning the binding of threads to CPUs. To further control execution
the MP_RESTRICT and MP_ISOLATE sysmp() commands can be used as usual.
To determine the currently requested CPU affinity the
pthread_getrunon_np() interface can be used. It returns the the caller's
CPU affinity (set by a previous call to pthread_setrunon_np()) in
cur_cpu.
DIAGNOSTICS
On success pthread_setrunon_np() and pthread_getrunon_np() return zero;
otherwise an error number is returned.
pthread_setrunon_np() may return:
[EPERM] The caller is not a PTHREAD_SCOPE_SYSTEM or a
PTHREAD_SCOPE_BOUND_NP thread.
[EINVAL] The cpu argument is not valid.
pthread_getrunon_np() may return:
[EPERM] The caller is not a PTHREAD_SCOPE_SYSTEM or a
PTHREAD_SCOPE_BOUND_NP thread.
[EINVAL] The caller has no affinity set.
SEE ALSOpthread_attr_setscope(3P), sysmp(2).
NOTES
The _np suffix indicates that this is a non-portable interface and is not
covered by any standard.
Page 1