Open System Services System Calls Reference Manual (G06.25+, H06.03+)

pthread_create(2) OSS System Calls Reference Manual
For the duration of the new threads existence, the system maintains and manages the thread
object and other thread state overhead.
The system assigns each new thread a thread identier, which the system writes into the address
specied by the thread parameter before the new thread executes.
At thread creation, the scheduling policy and scheduling parameters stored in the thread attri-
butes object passed to pthread_create() is used by default. If you want the scheduling attributes
to be inherited from the parent thread, then before creating the new thread your program must use
the pthread_attr_setinheritsched()
function with the inheritsched parameter set to
PTHREAD_INHERIT_SCHED
.
The signal state of the new thread is initialized as follows:
The signal mask is inherited from the creating thread.
The set of signals pending for the new thread is empty.
If pthread_create() fails, no new thread is created and the contents of the location indicated by
the thread parameter are undened.
Thread Termination
A thread terminates when one of the following occurs:
The thread returns from its start routine.
The thread calls the pthread_exit( ) function.
The thread is canceled.
When a thread terminates, the system performs these actions:
The system writes a return value (if one is available) into the terminated threads attri-
butes object, as follows:
If the thread has been canceled, the system writes the value
PTHREAD_CANCELED into the object specied by attr.
If the thread terminated by returning from its start routine, the system copies the
return value from the start routine (if one is available) into the object specied
by attr.
If the thread explictly called the pthread_exit() function, the system stores the
value received in the value_ptr parameter of pthread_exit( ) into the object
specied by attr.
Another thread can obtain this return value by joining with the terminated thread using
the pthread_join( ) function. If the thread terminated by returning from its start routine
normally and the start routine does not provide a return value, the results obtained by
joining with that thread are unpredictable.
If the termination results from a cancelation request or a call to pthread_exit( ), the sys-
tem calls, in turn, each cleanup handler that this thread declared using the
pthread_cleanup_push() macro that has not yet been removed using the
pthread_cleanup_pop() macro. (The system also transfers control to any appropriate
CATCH, CATCH_ALL,orFINALLY blocks.)
For C++: At normal exit from a thread, a program calls the appropriate destructor func-
tions, just as if an exception had been raised.
556 Hewlett-Packard Company 527186-003