p The following actions can be specified: l -enum -offset 2n t If .Fa psid is set to .Dv PS_QUERY , then the current processor set ID will be returned into .Fa psid , and no assignment will be performed. t If .Fa psid is set to .Dv PS_MYID , then the processor set ID of the calling process will be used, and .Fa psid will be ignored. t If .Fa psid is set to .Dv PS_NONE , any assignment to the processor will be cleared. .El t Fn pset_bind psid type id opsid Dedicates the processor set specified by .Fa psid to the target specified by .Fa id . The current processor set ID to which the target is bound or .Dv PS_NONE will be returned in .Fa opsid , if the pointer is not .Dv NULL . .Nx supports the following types of targets specified by .Fa type : l -tag -width P_LWPID -offset 2n t Dv P_PID Process identified by the PID. t Dv P_LWPID Thread of the calling process identified by the LID. .El
p The following actions can be specified: l -enum -offset 2n t If .Fa psid is set to .Dv PS_QUERY , then the current processor set ID to which the target is bound or .Dv PS_NONE will be returned in .Fa opsid , and no binding will be performed. t If .Fa psid is set to .Dv PS_MYID , then the processor set ID of the calling process will be used. t If .Fa psid is set to .Dv PS_NONE , the specified target will be unbound from the processor set. .El t Fn pset_destroy psid Destroys the processor set specified by .Fa psid . Before destroying the processor set, all related assignments of the processors will be cleared, and all bound threads will be unbound.
p If .Fa psid is .Dv PS_MYID , the processor set ID of the caller thread will be used. .El .Sh IMPLEMENTATION NOTES Except for .Dv PS_QUERY operations, these interfaces require super-user privileges.
p The .Fn pset_bind function can return the current processor set ID to which the target is bound, or .Dv PS_NONE . However, for example, the process may have many threads, which could be bound to different processor sets. In such a case it is unspecified which thread will be used to return the information.
p There is an alternative thread affinity interface, see .Xr affinity 3 . However, processor sets and thread affinity are mutually exclusive, hence mixing of these interfaces is prohibited. .Sh RETURN VALUES Upon successful completion these functions return 0. Otherwise, -1 is returned and .Va errno is set to indicate the error. .Sh EXAMPLES An example of code fragment, which assigns the CPU whose ID is 0, for current process: d -literal psetid_t psid; cpuid_t ci = 0; if (pset_create(&psid) < 0) err(EXIT_FAILURE, "pset_create"); /* Assign CPU 0 to the processor-set */ if (pset_assign(psid, ci, NULL) < 0) err(EXIT_FAILURE, "pset_assign"); /* Bind the current process to the processor-set */ if (pset_bind(psid, P_PID, P_MYID, NULL) < 0) err(EXIT_FAILURE, "pset_bind"); /* * At this point, CPU 0 runs only the current process. */ perform_work(); if (pset_destroy(psid) < 0) err(EXIT_FAILURE, "pset_destroy"); .Ed .Sh ERRORS The .Fn pset_create function fails if: l -tag -width Er t Bq Er ENOMEM No memory is available for creation of the processor set, or limit of the allowed count of the processor sets was reached. t Bq Er EPERM The calling process is not the super-user. .El
p The .Fn pset_assign function fails if: l -tag -width Er t Bq Er EBUSY Another operation is performing on the processor set. t Bq Er EINVAL .Fa psid or .Fa cpuid are invalid. t Bq Er EPERM The calling process is not the super-user, and .Fa psid is not .Dv PS_QUERY . .El
p The .Fn pset_bind function fails if: l -tag -width Er t Bq Er EBUSY Another operation is performing on the processor set. t Bq Er EINVAL .Fa psid or .Fa type are invalid. t Bq Er EPERM The calling process is not the super-user, and .Fa psid is not .Dv PS_QUERY . t Bq Er ESRCH The specified target was not found. .El
p The .Fn pset_destroy function fails if: l -tag -width Er t Bq Er EBUSY Another operation is performing on the processor set. t Bq Er EPERM The calling process is not the super-user. .El .Sh SEE ALSO .Xr affinity 3 , .Xr cpuset 3 , .Xr sched 3 , .Xr schedctl 8 .Sh STANDARDS This API is expected to be compatible with the APIs found in Solaris and HP-UX operating systems. .Sh HISTORY The processor sets appeared in .Nx 5.0 .