pthread_rwlockattr_getpshared() — Get the processed-shared read or write lock attribute

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_getpshared(const pthread_rwlockattr_t *attr, int *pshared);
SUSV3:
#define _UNIX03_THREADS 
#include <pthread.h>
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *
                                   __restrict__attr, 
                                  int * __restrict__pshared);

General description

The pthread_rwlockattr_getpshared() function gets the attribute pshared for the read or write lock attribute object attr. By using attr with the pthread_rwlockattr_getpshared() function you can determine its process-shared value for a read or write lock.

The valid values for the attribute pshared are:
PTHREAD_PROCESS_SHARED
Permits a read or write lock to be operated upon by any thread that has access to the memory where the read or write lock is allocated, even if the read or write lock is allocated in memory that is shared by multiple processes.
PTHREAD_PROCESS_PRIVATE
A read or write lock can only be operated upon by threads created within the same process as the thread that initialized the read or write lock. When a new process is created by the parent process it will receive a different copy of the private read or write lock and this new read or write lock can only be used to serialize between threads in the child process. The default value of the attributed is PTHREAD_PROCESS_PRIVATE.

Returned value

If successful, pthread_rwlockattr_getpshared() returns 0.

If unsuccessful, pthread_rwlockattr_getpshared() returns -1 and sets errno to one of the following values:
Error Code
Description
EINVAL
The value specified for attr is not valid.

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

Related information