DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

pthread_mutexattr_setpshared(3pthread)


pthread_mutexattr_setpshared, pthread_mutexattr_getpshared -- set, get process-shared attribute

Synopsis

   cc [options] -Kthread file
   

#include <pthread.h>

int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared); int pthread_mutexattr_getpshared(pthread_mutexattr_t *attr), int *pshared);

Description

The pthread_mutexattr_setpshared function sets the process-shared attribute in an initialized attributes object referenced by attr

The pthread_mutexattr_getpshared function obtains the value of the process-shared attribute from the attributes object referenced by attr and stores it in the object referenced by the pshared parameter.

The attr parameter is a pointer to a mutex attributes object. For pthread_mutexattr_setpshared, pshared is an object in which the value of the process-shared attribute of attr is stored. For pthread_mutexattr_getpshared pshared is a pointer to the object in which the value of the process-shared attribute of attr is stored.

The process-shared attribute is set to PTHREAD_PROCESS_SHARED to permit 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. If the process-shared attribute is PTHREAD_PROCESS_PRIVATE (the default), the mutex will only be operated upon by threads created within the same process as the thread that initialized the mutex; if threads of differing processes attempt to operate on such a mutex, the behavior is undefined.

Return values

pthread_mutexattr_setpshared and pthread_mutexattr_getpshared return zero on success. Otherwise, an error number is returned.

Diagnostics

The pthread_mutexattr_setpshared and pthread_mutexattr_getpshared functions may fail if:

EINVAL
The value specified by attr is invalid.

The pthread_mutexattr_setpshared function may fail if:


EINVAL
The new value specified for the attribute is outside the range of legal values for that attribute.

Standards Compliance

The Single UNIX Specification, Version 2; The Open Group.

References

Intro(3pthread), pthread_cond_init(3pthread), pthread_create(3pthread), pthread_mutex_init(3pthread), pthread_mutexattr_init(3pthread), pthread(4)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004