#include <sys/types.h> #include <sys/procset.h> #include <sys/processor.h>int processor_exbind(idtype_t idtype, id_t *idlist, int list_size, processorid_t processorid, processorid_t *obind);
processorid is the ID of a processor. This is an exclusive binding; the processor is precluded from running LWPs that are not exclusively bound.
idtype and idlist are used to identify a set of LWPs. If obind is not NULL, it points to a variable in which the previous binding is returned. idtype must be set to P_PID and idlist is a process ID list specifying the LWPs to be bound.
To exclusively bind or unbind a process or LWP, both of these conditions must be met:
The valid values for idtype and corresponding interpretations of idlist are as follows:
When the LWP identified by idlist has been bound, it will execute only on the processor specified by processorid (even if other processors are available), except briefly, if the LWP requires a resource that only another processor can provide. Once one or more LWPs are exclusively bound to a processor with a single call to processor_exbind, all subsequent requests fail with EBUSY, unless the current exclusive binding to the processor is undone or those LWPs exit. The processor so bound will not schedule any LWP that is not exclusively bound. The system imposes a limit on the number of processors that can be exclusively bound.
The processor_exbind call is not guaranteed to be synchronous with the binding operation. If the binding operation cannot be completed immediately, the call may return before the operation completes. Any delay between the return of the function and the completion of the operation will, typically, be of very short duration.
If processorid is PBIND_NONE, the specified LWP is unbound; that is, it is made free to run on any processor.
If the LWP(s) specified by idlist is already bound to a different processor, the binding for that LWP will be changed to the processor specified by processorid. If obind is not NULL and the LWP is currently bound to a processor, that processorid is returned by obind.
The processor binding is inherited by any children created by a fork(2) call, or _lwp_create(2), and does not change across a call to exec(2).
To bind or unbind an LWP the real or effective user ID of the caller must match the real or saved [from exec(2)] user ID of the process being bound or unbound, or the caller must have appropriate privileges.
On failure, processor_exbind returns a negative value and sets errno to identify the error.