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

p
pthread(3T) pthread(3T)
(Pthread Library)
pthread_detach()
Makes it unnecessary to "join" the thread. Thread resources are reaped by the
system at the time the thread terminates.
PTHREAD ATTRIBUTES
A set of thread attributes may be provided to
pthread_create()
. Any changes from default values
must be made to the attribute set before the call to
pthread_create()
is made. Subsequent changes
to the attribute set do not affect the created thread. However, the attribute set may be used in multiple
pthread_create()
calls.
Note that only the "detachstate", "schedparam", "schedpolicy", and "processor" attributes of a thread may be
effected subsequent to thread creation. However, this is done by the
pthread_detach()
,
pthread_setschedparam()
, and
pthread_processor_bind_np()
functions, respectively.
pthread_attr_init()
Initializes an attribute set for use in the
pthread_create()
call.
pthread_attr_destroy()
Destroys the content of an attribute set.
pthread_attr_getdetachstate()
,
pthread_attr_getguardsize()
,
pthread_attr_getinheritsched()
,
pthread_attr_getprocessor_np()
,
pthread_attr_getschedparam()
,
pthread_attr_getschedpolicy()
,
pthread_attr_getscope()
,
pthread_attr_getstackaddr()
,
pthread_attr_getstacksize()
,
pthread_attr_setdetachstate()
,
pthread_attr_setguardsize()
,
pthread_attr_setinheritsched()
,
pthread_attr_setprocessor_np()
,
pthread_attr_setschedparam()
,
pthread_attr_setschedpolicy()
,
pthread_attr_setscope()
,
pthread_attr_setstackaddr()
,
pthread_attr_setstacksize()
These pthread_attr_get/set<attribute>()
functions get/set the associated attribute in
the attribute set. See the manpages for these functions for descriptions of the attributes.
pthread_default_stacksize_np()
This is used to set the default stacksize for threads created in subsequent attribute set initializations
(calls to
pthread_attr_init()
)orinpthread_create() where no attributes are supplied.
CANCELLATION
Certain applications may desire to terminate a particular thread without causing the entire process to exit.
A thread may be canceled by another thread in the same process while the cancellation target thread exe-
cutes a system call or particular library routine.
When a thread issues a cancel request against another thread, the target thread can check to see if a
request is pending against it by the
pthread_testcancel() interface. When called with a request
pending, the target thread terminates after executing any cleanup handlers which may have been installed.
Cleanup handlers may be used to delete any dynamic storage allocated by the canceled thread, to unlock a
mutex, or other operations.
Typically, the cancellation type for a thread is deferred. That is, cancellation requests are held pending
until the thread reaches a cancellationpoint which is simply one of a list of library functions and system
calls (see lists below).
The thread may set its cancellation type to asynchronous. In this case cancellation requests are acted upon
at any time. This can be used effectively in compute-bound threads which do not call any functions that are
cancellation points.
pthread_cancel() Cancel execution of a given thread.
pthread_testcancel() Called by a thread to process pending cancel requests.
pthread_setcancelstate(),
pthread_setcanceltype()
174 Hewlett-Packard Company 2 HP-UX 11i Version 2: December 2007 Update