|
|
#include <sys/types.h> #include <sys/procset.h> #include <sys/processor.h>int processor_bind(idtype_t idtype, id_t id, processorid_t processorid, processorid_t *obind);
idtype specifies whether the id argument is the Light Weight Process ID (LWP ID) for a single LWP within the caller's process, or a process ID (PID). If id is a PID, then the operation applies to all the LWPs associated with the given process. To bind or unbind a process or LWP, the real or effective user ID of the caller must match the real or saved user ID [from exec(2)] of the process being bound or unbound, or the caller must have the P_OWNER privilege.
processorid is the ID of a processor to which the given PID or LWP ID is to be bound.
If obind is not NULL, it points to a variable in which the previous binding is returned.
The valid values for idtype and corresponding interpretations of id are as follows:
When the process identified by id has been bound, it will execute only on the processor specified by processorid (even if other processors are available), except briefly, if the process requires a resource that only another processor can provide. The processor may continue to run other processes. in addition to the one specified by id. The processor_bind call will fail if the process specified by id is bound exclusively to another processor or if there are already processes exclusively bound to the processor specified by processorid.
The processor_bind 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 process is unbound; that is, it is made free to run on any processor.
Using a processorid of PBIND_QUERY queries the binding of a process without changing it. This action requires P_OWNER privilege if the target process UID does not match.
If the process specified by id is already bound to a different processor, the binding for that process will be changed to the processor specified by processorid. If obind is not NULL and the process 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).
On failure, processor_bind returns a negative value and sets errno to identify the error.