DragonFly On-Line Manual Pages
PTHREAD_SETAFFINITY_NP(3) DragonFly Library Functions Manual
NAME
pthread_setaffinity_np, pthread_getaffinity_np - set and get the thread's
CPU affinity mask
LIBRARY
POSIX Threads Library (libpthread, -lpthread)
SYNOPSIS
#include <pthread.h>
#include <pthread_np.h>
int
pthread_setaffinity_np(pthread_t tid, size_t cpusetsize,
const cpu_set_t *mask);
int
pthread_getaffinity_np(pthread_t tid, size_t cpusetsize,
cpu_set_t *mask);
DESCRIPTION
The pthread_setaffinity_np() sets the CPU affinity mask of the thread
identified by tid to the value specified by the mask. The cpusetsize is
the length (in bytes) of the data pointed to by mask. Normally this
argument would be specified as sizeof(cpu_set_t). If the thread
specified by the tid is the current thread, it will be migrated
immediately, if necessary, otherwise it will be migrated by the scheduler
later.
A process created by fork(2), vfork(2), and rfork(2) inherits the calling
thread's CPU affinity mask. Same applies to the threads created by
lwp_create(2), and the threads created by pthread_create(3).
pthread_getaffinity_np() writes the affinity mask of the thread
identified by the tid to the cpu_set_t structure pointed to by mask.
The cpu_set_t data structure represents a set of CPUs. See
sched_setaffinity(2) for details.
RETURN VALUES
If successful, these functions will return zero. Otherwise an error
number will be returned to indicate the error.
ERRORS
The pthread_setaffinity_np() and pthread_getaffinity_np() will fail if:
[EFAULT] The mask parameter is outside the process's allocated
address space.
[EINVAL] The tid parameter is invalid.
[ESRCH] The thread identified by the tid does not exist.
[EPERM] The mask does not contain a valid CPU.
SEE ALSO
fork(2), lwp_create(2), lwp_getaffinity(2), lwp_setaffinity(2), rfork(2),
sched_getaffinity(2), sched_setaffinity(2), vfork(2), pthread_create(3)
HISTORY
The pthread_setaffinity_np() and pthread_getaffinity_np() functions first
appeared in DragonFly 4.7.
DragonFly 6.3-DEVELOPMENT January 14, 2017 DragonFly 6.3-DEVELOPMENT