ptg10805159
440 Thread Control Chapter 12
The only attribute supported for reader–writer locks is theprocess-sharedattribute.
It is identical to the mutexprocess-sharedattribute. Just as with the mutexprocess-shared
attributes, a pair of functions is provided to get and set theprocess-sharedattributes of
reader–writer locks.
#include <pthread.h>
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *
restrict attr,
int *restrict pshared);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr,
int pshared);
Both return: 0 if OK, error number on failure
Although POSIX defines only one reader–writer lock attribute, implementations arefree
to define additional, nonstandardones.
12.4.3 ConditionVariable Attributes
The Single UNIX Specification currently defines two attributes for condition variables:
theprocess-sharedattribute and theclockattribute. As with the other attribute objects, a
pair of functions initialize and deinitialize condition variable attribute objects.
#include <pthread.h>
int pthread_condattr_init(pthread_condattr_t *attr);
int pthread_condattr_destroy(pthread_condattr_t *attr);
Both return: 0 if OK, error number on failure
Theprocess-sharedattribute is the same as with the other synchronization attributes.
It controls whether condition variables can be used by threads within a single process
only or from within multiple processes. Tofind the current value of theprocess-shared
attribute, we use thepthread_condattr_getpsharedfunction. Toset its value, we
use thepthread_condattr_setpsharedfunction.
#include <pthread.h>
int pthread_condattr_getpshared(const pthread_condattr_t *
restrict attr,
int *restrict pshared);
int pthread_condattr_setpshared(pthread_condattr_t *attr,
int pshared);
Both return: 0 if OK, error number on failure
Theclock attribute controls which clock is used when evaluating the timeout
argument (tsptr) of thepthread_cond_timedwaitfunction. The legal values arethe