processor_bind(2) processor_bind(2)
NAME
processor_bind - bind or unbind to a processor
SYNOPSIS
#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);
DESCRIPTION
processor_bind binds a process, an LWP, or set of LWPs to a
specific processor. processorid is the ID of a processor.
idtype and id are used to identify the processes or LWPs 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:
P_PID id is a process ID. The operation shall apply to all
LWPs currently associated with the specified process.
P_LWPID id is an LWP ID specifying a single LWP, within the
same process as the caller, to which the operation
shall apply.
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.
Copyright 1994 Novell, Inc. Page 1
processor_bind(2) processor_bind(2)
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).
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.
Return Values
On success, processor_bind returns 0. if obind is not NULL,
the previous binding of the specified LWP shall be returned in
the location pointed to by obind. If obind is not NULL and
idtype and id specify more than one LWP, the previous binding
shall be returned for a random LWP within the specified set.
The previous binding shall be the processor ID of the
processor to which the LWP was bound, or PBIND_NONE if the LWP
was previously unbound.
On failure, processor_bind returns a negative value and sets
errno to identify the error.
Errors
In the following conditions, processor_bind fails and sets
errno to:
EPERM The calling process does not have appropriate privilege.
EINVAL An invalid idtype or processorid was specified, or the
specified processor is currently offline.
ESRCH None of the specified LWPs exist or idtype was P_LWPID
and id specified an LWP that was not within the
caller's process.
EBUSY The process specified by id is bound exclusively to
another processor or there are already processes or
LWPs exclusively bound to the processor specified by
processorid.
Copyright 1994 Novell, Inc. Page 2
processor_bind(2) processor_bind(2)
EFAULT obind is not NULL and points to an invalid address.
EIO The specified processor is not operational.
REFERENCES
pbind(1M), pexbind(1M)
NOTICES
Considerations for Lightweight Processes
In addition to binding processes to a processor, the P_LWPID
idtype (see DESCRIPTION) can be used by a process to bind
individual LWPs in that process. There is no way for a
process to bind LWPs in another process.
Copyright 1994 Novell, Inc. Page 3