| CPU_LEVEL_ROOT Root set
CPU_LEVEL_CPUSET Assigned set
CPU_LEVEL_WHICH Set specified by which argument
The which argument determines how the value of id is interpreted and is of type cpuwhich_t. The which argument may have the following values:
| CPU_WHICH_TID id is lwpid_t (thread id)
CPU_WHICH_PID id is pid_t (process id)
CPU_WHICH_CPUSET id is a cpusetid_t (cpuset id)
CPU_WHICH_IRQ id is an irq number
An id of -1 may be used with a which of CPU_WHICH_TID, CPU_WHICH_PID, or CPU_WHICH_CPUSET to mean the current thread, process, or current threads cpuset. All cpuset syscalls allow this usage.
A level argument of CPU_LEVEL_WHICH combined with a which argument other than CPU_WHICH_CPUSET refers to the anonymous mask of the object. This mask does not have an id and may only be manipulated with cpuset_setaffinity(2).
cpuset creates a new set containing the same CPUs as the root set of the current process and stores its id in the space provided by setid. On successful completion the calling process joins the set and is the only member. Children inherit this set after a call to fork(2).
cpuset_setid attempts to set the id of the object specified by the which argument. Currently CPU_WHICH_PID is the only acceptable value for which as threads do not have an id distinct from their process and the API does not permit changing the id of an existing set. Upon successful completion all of the threads in the target process will be running on CPUs permitted by the set.
cpuset_getid retrieves a set id from the object indicated by which and stores it in the space pointed to by setid. The retrieved id may be that of either the root or assigned set depending on the value of level. level should be CPU_LEVEL_CPUSET or CPU_LEVEL_ROOT to get the set id from the process or thread specified by the id argument. Specifying CPU_LEVEL_WHICH with a process or thread is unsupported since this references the unnumbered anonymous mask.
The following error codes may be set in errno:
[EINVAL] The which or level argument was not a valid value. [EDEADLK] The cpuset_setid call would leave a thread without a valid CPU to run on because the set does not overlap with the threads anonymous mask. [EFAULT] The setid pointer passed to cpuset_getid or cpuset was invalid. [ESRCH] The object specified by the id and which arguments could not be found. [EPERM] The calling process did not have the credentials required to complete the operation. [ENFILE] There was no free cpusetid_t for allocation.
cpuset(1), cpuset_getaffinity(2), cpuset_setaffinity(2), pthread_affinity_np(3), pthread_attr_affinity_np(3)
The cpuset family of system calls first appeared in
.Fx 7.1 .
.An Jeffrey Roberson Aq jeff@FreeBSD.org