HP-UX Reference (11i v2 07/12) - 3 Library Functions N-Z (vol 7)

p
pthread_processor_bind_np(3T) pthread_processor_bind_np(3T)
(Pthread Library)
The pthread_ldom_id_np()
function obtains the locality domain ID of a specific locality domain on
the system. The locality domain ID is returned in answer. The request parameter determines the precise
action to be taken and is one of the following:
PTHREAD_GETFIRSTLDOM_NP
This request stores in the answer parameter the ID of the first locality domain in the processor
set of the calling thread. The ldom argument is ignored.
PTHREAD_GETNEXTLDOM_NP
This request stores in the answer parameter the ID of the next locality domain in the processor
set of the calling thread after ldom.
Typically,
PTHREAD_GETFIRSTLDOM_NP
is called to determine the first ldom.
PTHREAD_GETNEXTLDOM_NP
is then called in a loop (until the call returns [EINVAL]) to
determine the IDs of the remaining ldoms.
The
pthread_spu_to_ldom_np()
function returns the ID of the locality domain containing the pro-
cessor specified by spu. The locality domain ID is returned in ldom.
Processor Set Binding
All threads have binding or association to a processor set, and they execute on processors within that set.
The
pthread_pset_bind_np()
function allows a thread to change its binding to another processor
set. The thread needs EXEC permission to bind to another processor set (See pset_bind(2) for details). The
thread’s contention scope must be
PTHREAD_SCOPE_SYSTEM
to change a thread’s processor set binding.
The thread specified by tid is the target thread whose binding is changed. The pset parameter specifies the
new processor set for tid. The new processor set for the thread is returned in answer.
The tid
PTHREAD_SELFTID_NP
can be used to refer to the calling thread. The pset
PTHREAD_PSETNOCHANGE_NP
can be used to read the current processor set assignment for the thread.
Processor Binding
Processor binding is expected to be used to increase performance in certain applications to prevent cache
thrashing or to cause threads to execute in parallel on different processors. It should not be used to ensure
correctness of an application. Specifically, cooperating threads should not rely on processor assignment in
lieu of a synchronization mechanism (such as mutexes).
Processor binding and locality domain binding is mutually exclusive - only one can be in effect at any time.
If locality domain binding is in effect, the target is allowed to execute on any processor within that locality
domain.
Due to the capability of online addition and deletion of processors on some platforms, processors may go
away. If this occurs, any threads bound to a departing processor will be rebound to a different processor
with the same binding type.
The
pthread_processor_bind_np()
function binds a thread to a specific processor. The thread
specified by tid is the target thread whose binding is changed. The spu parameter specifies the new proces-
sor binding for tid. The request parameter determines the precise action to be taken and is one of the fol-
lowing:
PTHREAD_BIND_ADVISORY_NP
This call is advisory. This request assigns thread tid to processor spu. The new processor
assignment is returned in answer.
The tid PTHREAD_SELFTID_NP can be used to refer to the calling thread.
The spu PTHREAD_SPUNOCHANGE_NP may be passed to read the current assignment. The
spu PTHREAD_SPUFLOAT_NP may be used to break any specific processor assignment and
allow the implementation to choose which processor the thread should execute on when it is
scheduled to execute. This allows the thread to run on any processor the implementation
chooses.
This request is only advisory. If the scheduling policy for the thread conflicts with this processor
assignment, the scheduling policy shall overrule the processor assignment. For example, when a
processor is ready to choose another thread to execute, if the highest priority SCHED_FIFO
thread on the run queue is bound to a different processor, that thread will execute on the avail-
able processor rather than waiting for the processor to which it is bound.
PTHREAD_BIND_FORCED_NP
This request is identical to PTHREAD_BIND_ADVISORY_NP except that this thread to
252 Hewlett-Packard Company − 3 − HP-UX 11i Version 2: December 2007 Update