pthread_condattr(3T) SDK R4.11 pthread_condattr(3T)
NAME
pthread_condattr: pthread_condattr_init, pthread_condattr_destroy,
pthread_condattr_getpshared, pthread_condattr_setpshared - manipulate
condition initialization attributes
SYNOPSIS
#include <pthread.h>
int pthread_condattr_init(pthread_condattr_t *attr);
int pthread_condattr_destroy(pthread_condattr_t *attr);
int pthread_condattr_getpshared(pthread_condattr_t *attr,
int *pshared);
int pthread_condattr_setpshared(pthread_condattr_t *attr,
int pshared);
where:
attr A pointer to a condition attributes object
pshared For pthread_condattr_getpshared(), a pointer to a location
to store the process-shared attribute; for
pthread_condattr_setpshared(), 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 pthread_condattr_init() function initializes a condition
attributes object with the default value for the process-shared
attribute. In a call to pthread_cond_init(), passing a pointer to
such a newly initialized condition attributes object is equivalent to
passing a NULL pointer.
The pthread_condattr_destroy() function destroys the condition
attributes object pointed to by attr.
The pthread_condattr_setpshared() function is used to set the
process-shared attribute in an initialized attributes object pointed
to by attr. The pthread_condattr_getpshared() 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
pthread_cond_init(), 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, pthread_condattr_init(),
pthread_condattr_setpshared(), and pthread_condattr_destroy() return
0. Otherwise each returns -1 and sets errno to indicate the error.
If successful, pthread_condattr_getpshared() 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, pthread_condattr_destroy(),
pthread_condattr_getpshared(), and pthread_condattr_setpshared()
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 pthread_condattr_init()
or has been corrupted.
For each of the following conditions, pthread_condattr_setpshared()
returns -1 and sets errno to the corresponding value:
[EINVAL] The value given by pshared is not 0 or 1.
SEE ALSO
pthread_cond_init(3T), pthread_cond_wait(3T),
pthread_cond_timedwait(3T), pthread_cond_signal(3T),
pthread_cond_broadcast(3T), pthread_mutexattr_init(3T),
pthread_mutex_init(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)