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

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/nan.3m
________________________________________________________________
___ ___
p
pthread_processor_bind_np(3T) pthread_processor_bind_np(3T)
(Pthread Library)
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 assign-
ment 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 proces-
sor binding will over rule the scheduling policy. 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 not be chosen by the available processor. That
thread will wait until the wanted processor becomes available. The available processor will
choose a lower priority thread to execute instead of completely honoring the scheduling policies.
Note: binding a thread to a specific processor essentially changes the scheduling allocation domain size for
that thread to be one. Having a thread float and be scheduled on whatever processor the system chooses
sets a thread’s scheduling allocation domain size to a value greater than one (it will generally be equal to
the number of processors on the system).
Locality Domain Binding
Locality domain 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 locality domain
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, locality domains may
go away. If the last processor in a locality domain is removed, any threads bound to a departing locality
domain will be rebound to a different locality domain.
The pthread_ldom_bind_np() function binds a thread to a specific locality domain. The new locality
domain binding is returned in answer.
The thread specified by tid is the target thread whose binding is changed. The value
PTHREAD_SELFTID_NP
can be used to refer to the calling thread.
HP-UX Release 11i: December 2000 3 Section 3707
___
___