Standards / Extensions | C or C++ | Dependencies |
---|---|---|
z/OS UNIX |
both | POSIX(ON) |
#define _OPEN_THREADS
#include <pthread.h>
int pthread_rwlock_init(pthread_rwlock_t *rwlock, pthread_rwlockattr_t *attr);
pthread_rwlock_t rwlock=PTHREAD_RWLOCK_INITIALIZER;
#define _UNIX03_THREADS
#include <pthread.h>
int pthread_rwlock_init(pthread_rwlock_t * __restrict__rwlock,
const pthread_rwlockattr_t * __restrict__attr);
The pthread_rwlock_init() function creates a read or write lock, referenced by rwlock, with attributes specified by attr. If attr is NULL, the default read or write lock attribute (PTHREAD_PROCESS_PRIVATE) is used. Once initialized, the lock can be used any number of times without being reinitialized. Upon successful initialization, the state of the read or write lock becomes initialized and unlocked.
In cases where default read or write lock attributes are appropriate, the macro PTHREAD_RWLOCK_INITIALIZER can be used to initialize read or write locks that are statically allocated. The effect is equivalent to dynamic initialization by a call to pthread_rwlock_init() with parameter attr specified as NULL, except that no error checking is done.
If successful, pthread_rwlock_init() returns 0, and the state of the read or write lock becomes initialized and unlocked.
Special behavior for Single UNIX Specification, Version 3: If unsuccessful, pthread_rwlock_init() returns an error number to indicate the error.