pthread_condattr(3T) DG/UX R4.11MU05 pthread_condattr(3T)
NAME
pthreadcondattr: pthreadcondattrinit, pthreadcondattrdestroy,
pthreadcondattrgetpshared, pthreadcondattrsetpshared - manipulate
condition initialization attributes
SYNOPSIS
#include <pthread.h>
int pthreadcondattrinit(pthreadcondattrt *attr);
int pthreadcondattrdestroy(pthreadcondattrt *attr);
int pthreadcondattrgetpshared(pthreadcondattrt *attr,
int *pshared);
int pthreadcondattrsetpshared(pthreadcondattrt *attr,
int pshared);
where:
attr A pointer to a condition attributes object
pshared For pthreadcondattrgetpshared(), a pointer to a location
to store the process-shared attribute; for
pthreadcondattrsetpshared(), the new value of the process-
shared attribute.
DESCRIPTION
Condition attributes objects are used to control the initialization
of conditions in a way similar to which thread attributes objects are
used to control the creation of threads.
DG/UX supports the process-shared attribute for condition variables.
This attribute can have a value of 0 or 1. A value of 0 (default)
indicates that condition variables initialized with this condition
attributes object are only allowed to be operated upon by threads
within the the current process. A value of 1 indicates that
condition variables initialized with this condition attributes object
are allowed to be operated upon by threads in all processes that have
access to the memory in which the condition is allocated. Whenever
possible, the default value of 0 for the process-shared attribute
should be used, as intraprocess condition variables are more
efficient than interprocess condition variables.
The pthreadcondattrinit() function initializes a condition
attributes object with the default value for the process-shared
attribute. In a call to pthreadcondinit(), passing a pointer to
such a newly initialized condition attributes object is equivalent to
passing a NULL pointer.
The pthreadcondattrdestroy() function destroys the condition
attributes object pointed to by attr.
The pthreadcondattrsetpshared() function is used to set the
process-shared attribute in an initialized attributes object pointed
to by attr. The pthreadcondattrgetpshared() function returns the
value of the process-shared attribute from the attributes object
pointed to by attr.
After a condition attributes object has been used in a call to
pthreadcondinit(), it is no longer associated with the initialized
condition variable. The condition attributes object can be freely
destroyed, modified, or used again to initialize another condition
variable.
DIAGNOSTICS
Returns
If successful, pthreadcondattrinit(),
pthreadcondattrsetpshared(), and pthreadcondattrdestroy() return
0. Otherwise each returns -1 and sets errno to indicate the error.
If successful, pthreadcondattrgetpshared() returns 0 and stores the
value of the process-shared attribute from the condition attributes
object pointed to by attr into the location pointed to by pshared;
otherwise it returns -1 and sets errno to indicate the error.
Errors
For each of the following conditions, pthreadcondattrdestroy(),
pthreadcondattrgetpshared(), and pthreadcondattrsetpshared()
return -1 and set errno to the corresponding value:
[EINVAL] An invalid condition attributes object has been specified.
This occurs when DG/UX has detected that the condition
attributes object pointed to by attr has not been
initialized by a previous call to pthreadcondattrinit()
or has been corrupted.
For each of the following conditions, pthreadcondattrsetpshared()
returns -1 and sets errno to the corresponding value:
[EINVAL] The value given by pshared is not 0 or 1.
SEE ALSO
pthreadcondinit(3T), pthreadcondwait(3T),
pthreadcondtimedwait(3T), pthreadcondsignal(3T),
pthreadcondbroadcast(3T), pthreadmutexattrinit(3T),
pthreadmutexinit(3T).
NOTES
The DG/UX system defines the symbol {_POSIX_THREADS_PROCESS_SHARED},
indicating that it supports the process-shared attribute for mutexes
and condition variables.
An application need not be multi-threaded to use process-shared
condition variables. However, it must compile and link against the
thread interfaces. Process-shared condition variables are
significantly faster than traditional Unix semaphores, particularly
in the uncontended cases.
Licensed material--property of copyright holder(s)