DragonFly On-Line Manual Pages
LWP_SETAFFINITY(2) DragonFly System Calls Manual LWP_SETAFFINITY(2)
NAME
lwp_setaffinity, lwp_getaffinity -- set and get a LWP's CPU affinity mask
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <sys/lwp.h>
int
lwp_setaffinity(pid_t pid, lwpid_t tid, const cpumask_t *mask);
int
lwp_getaffinity(pid_t pid, lwpid_t tid, cpumask_t *mask);
DESCRIPTION
The lwp_setaffinity() system call sets the CPU affinity mask of the LWP,
which is identified by the pid and the tid, to the value specified by the
mask. If the pid is zero, then the pid of the calling process is used.
If the tid is less than zero, then all LWPs of the process identified by
the pid are affected. If the LWP specified by the pid and the tid is the
current LWP 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
LWP's CPU affinity mask. Same applies to the LWPs created by
lwp_create(2), and the threads created by pthread_create(3).
lwp_getaffinity() writes the affinity mask of the LWP, which is
identified by the pid and the tid, to the cpumask_t structure pointed to
by mask. If the pid is zero, then the pid of the calling process is
used. If the tid is less than zero, then the first LWP of specified
process is used.
RETURN VALUES
These system calls return -1 on error and 0 upon successful completion.
ERRORS
The lwp_setaffinity() and lwp_getaffinity() system calls will fail if:
[EFAULT] The name parameter is outside the process's allocated
address space.
[EINVAL] The pid parameter is negative.
[ESRCH] The LWP identified by the pid and the tid does not
exist.
[EPERM] The mask does not contain a valid CPU.
SEE ALSO
fork(2), lwp_create(2), rfork(2), sched_getaffinity(2),
sched_setaffinity(2), vfork(2), pthread_create(3),
pthread_getaffinity_np(3), pthread_setaffinity_np(3)
HISTORY
The lwp_setaffinity() and lwp_getaffinity() functions first appeared in
DragonFly 4.7.
DragonFly 4.7 January 14, 2017 DragonFly 4.7