Open System Services Programmer's Guide
Attributes Defined by Threads Macros
The attributes of Standard POSIX Threads are determined by macros in unistd.h. Table 55 lists
the principal macros that influence the HP implementation for NonStop servers.
Table 55 Attributes of Standard POSIX Threads Defined by Macros
Description in Standard POSIX ThreadsMacro or Attribute
Not defined. A mutex or condition variable can be
operated on only by threads in the same process that
initialized the mutex or condition variable.
Mutex and condition variable initialization attributes:
_POSIX_THREAD_PROCESS_SHARED
Not defined. Threads are created with the
PTHREAD_SCOPE_PROCESSscheduling contention scope
Thread scheduling attribute:
_POSIX_THREAD_PRIORITY_SCHEDULING
by default. Threads contend directly with other threads
within their process. This attribute cannot be altered.
The scheduling allocation domain size is 1. Threads are
always bound to the same processor as the parent thread.
Has the value PTHREAD_EXPLICIT_SCHED. The
scheduling policy and associated attributes, such as
Thread scheduling attribute:
inheritsched
priority, are set to the corresponding values from the
attributes object during thread creation.
This attribute can be altered to
PTHREAD_INHERIT_SCHED (so that the scheduling policy
and attributes are inherited from the creating thread) by
using pthread_attr_setinheritsched().
The default value is SCHED_FIFO. This attribute cannot be
altered.
Thread scheduling attribute:
schedpolicy
Not defined. The prioceiling and protocol attributes
are not defined.
Mutex initialization scheduling attributes:
_POSIX_THREAD_PRIO_INHERIT
_POSIX_THREAD_PRIO_PROTECT
Defined. The thread creation stack size attribute can be
set in the attribute object.
Thread creation attribute:
_POSIX_THREAD_ATTR_STACKSIZE
Not defined. The location of the storage to be used for the
stack of the created thread cannot be altered.
Thread creation attribute:
_POSIX_THREAD_ATTR_STACKADDR
The default value is PTHREAD_CREATE_JOINABLE (that
is, storage associated with the thread is reclaimed when
the thread that created it calls a join()).
Thread creation attribute:
detachstate
This attribute can be altered using
pthread_attr_setdetachstate().
Signal Handling
There are two basic types of signals:
• Synchronous signals represent events that occur inside a process.
Synchronous signals occur immediately after the instruction that caused the event—for example,
attempting to divide by zero. A synchronous signal is associated with the thread that is
executing when the event occurs. A thread can install signal handlers (using the sigaction()
function) for the synchronous signals that occur during its execution. For terminating signals,
the default behavior is to terminate the process.
• Asynchronous signals represent events external to a process.
A thread can wait for a set of asynchronous signals using the spt_sigwait() function. If
a thread is waiting for a type of signal that is received, the thread is awakened and if a signal
handler has been installed, it is invoked, and the signal is considered handled; otherwise, the
Standard POSIX Threads 315