pthread_mutexattr_getpshared() — Get the process-shared mutex attribute
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
z/OS UNIX |
both | POSIX(ON) |
Format
#define _OPEN_THREADS
#include <pthread.h>
int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared);
SUSV3:
#define _UNIX03_THREADS
#include <pthread.h>
int pthread_mutexattr_getpshared(const pthread_mutexattr_t *__restrict__attr,
int * __restrict__ pshared);
General description
The pthread_mutexattr_getpshared() function gets the attribute pshared for the mutex attribute object attr. By using attr with the pthread_mutexattr_getpshared() function you can determine its process-shared value for a mutex.
The valid values for the attribute pshared are:
- PTHREAD_PROCESS_SHARED
- Permits a mutex to be operated upon by any thread that has access to the memory where the mutex is allocated, even if the mutex is allocated in memory that is shared by multiple processes.
- PTHREAD_PROCESS_PRIVATE
- A mutex can only be operated upon by threads created within the same process as the thread that initialized the mutex. When a new process is created by the parent process it will receive a different copy of the private mutex and this new mutex can only be used to serialize between threads in the child process. The default value of the attribute is PTHREAD_PROCESS_PRIVATE.
Returned value
If successful, pthread_mutexattr_getpshared() returns 0.
If unsuccessful, pthread_mutexattr_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_mutexattr_getpshared() returns an error number to indicate the error.