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

p
pthread(3T) pthread(3T)
(Pthread Library)
Set the characteristics of cancellation for the thread. Cancellation may be enabled or disabled, or it
may be synchronous or deferred.
pthread_cleanup_pop()
,
pthread_cleanup_push()
Register or remove cancellation cleanup handlers.
Refer to thread_safety(5) for the list of cancellation points in the pthread library, system functions, and libc.
For libc functions, whether the thread is cancelled depends upon what action is performed while executing
the function. If the thread blocks while inside the function, a cancellation point is created (i.e., the thread
may be cancelled). Other libraries may have cancellation points. Check the associated documentation for
details.
The list of cancellation points will vary from release to release. In general, if a function can return with an
[EINTR] error, chances are that it is a cancellation point.
SCHEDULING
Threads may individually control their scheduling policy and priorities. Threads may also suspend their
own execution, or that of other threads. Finally, threads are given some control over allocation of processor
resources.
pthread_suspend()
This function is used to temporarily stop the execution of a thread.
pthread_continue()
,
pthread_resume_np()
These functions cause a previously suspended thread to continue execution.
pthread_num_processor_np()
,
pthread_processor_bind_np()
,
pthread_processor_id_np()
These functions are used to interrogate processor configuration and to bind a thread to a specific pro-
cessor.
pthread_getconcurrency()
,
pthread_setconcurrency()
These functions are used to control the actual concurrency for unbound threads.
pthread_getschedparam()
,
pthread_setschedparam()
These functions are used to manipulate the scheduling policy and priority for a thread.
sched_get_priority_max()
,
sched_get_priority_min()
These functions are used to interrogate the priority range for a given scheduling policy.
sched_yield This function is used by a thread to yield the processor to other threads of equal or
greater priority.
COMMUNICATION & SYNCHRONIZATION
Multi-threaded applications concurrently execute instructions. Access to process-wide (or interprocess)
shared resources (memory, file descriptors, etc.) requires mechanisms for coordination or synchronization
among threads. The libpthread library offers synchronization primitives necessary to create a deterministic
application. A multithreaded application ensures determinism by forcing asynchronous thread contexts to
synchronize, or serialize, access to data structures and resources managed and manipulated during run-
time. These are mutual-exclusion (mutex) locks, condition variables, and read-write locks. The HP-UX
operating system also provides POSIX semaphores (see next section).
Mutexes furnish the means to exclusively guard data structures from concurrent modification. Their proto-
col precludes more than one thread which has locked the mutex from changing the contents of the pro-
tected structure until the locker performs an analogous mutex unlock. A mutex can be initialized in two
ways: by a call to pthread_mutex_init(); or by assignment of PTHREAD_MUTEX_INITIALIZER.
Condition Variables are used by a thread to wait for the occurrence of some event. A thread detecting or
causing such an event can signal or broadcast that occurrence to the waiting thread or threads.
HP-UX 11i Version 2: December 2007 Update 3 Hewlett-Packard Company 175