pthread_rwlockattr_init() — Initialize a read or write lock attribute object

Standards

Standards / Extensions C or C++ Dependencies

z/OS UNIX
Single UNIX Specification, Version 3

both

POSIX(ON)
OS/390 V2R7

Format

#define _OPEN_THREADS
#include <pthread.h>

int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);
SUSV3:
#define _UNIX03_THREADS
#include <pthread.h>

int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);

General description

The pthread_rwlockattr_init() function initializes a read or write lock attribute object. A read or write lock attribute object allows you to manage the characteristics of read or write locks in your application. It defines the set of values to be used for the read or write lock during its creation. By establishing a read or write lock attribute object, you can create many read or write locks with the same set of characteristics, without needing to define the characteristics for each and every read or write lock.

For a valid read or write lock attribute, refer to pthread_rwlockattr_setpshared() — Set the process-shared read or write lock attribute.

If pthread_rwlockattr_init() is called specifying an already initialized read or write lock attributes object the request is rejected and the current lock attributes object is unchanged.

Returned value

If successful, pthread_rwlockattr_init() returns 0.

If unsuccessful, pthread_rwlockattr_init() returns -1 and sets errno to one of the following values:
Error Code
Description
ENOMEM
There is not enough memory to initialize attr.

Special behavior for Single UNIX Specification, Version 3: If unsuccessful, pthread_rwlockattr_init() returns an error number to indicate the error.

Related information