pthread_setrunon_np(3P) pthread_setrunon_np(3P)
pthread_setrunon_np, pthread_getrunon_np - thread CPU scheduling affinity
#include <pthread.h>
int pthread_setrunon_np(int cpu);
int pthread_getrunon_np(int *cur_cpu);
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() interface with the MP_MUSTRUN command. 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.
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.
pthread_attr_setscope(3P), sysmp(2).
The _np suffix indicates that this is a non-portable interface and is not
covered by any standard.
PPPPaaaaggggeeee 1111 [ Back ]
|