Name
pthread_mutex_init
- create a mutex
Library
libc_r.lib
libpthread.lib
libthr.lib
Synopsis
|
int
pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr);
|
Return values
If successful,
pthread_mutex_init
will return zero and put the new mutex id into
mutex,
otherwise an error number will be returned to indicate the error.
Detailed description
The
pthread_mutex_init
function creates a new mutex, with attributes specified with
attr.
If
attr
is NULL the default attributes are used.
Examples
pthread_mutexattr_t mta;
int rc;
/* Initialize a mutex attributes object */
if((rc=pthread_mutexattr_init(&mta)) != 0) {
fprintf(stderr,"Error at pthread_mutexattr_init(), rc=%d\n",rc);
return -1;
}
Errors
The
pthread_mutex_init
function will fail if:
[EINVAL]
|
|
The value specified by
attr
is invalid.
|
[ENOMEM]
|
|
The process cannot allocate enough memory to create another mutex.
|
See also
pthread_mutex_destroy,
pthread_mutex_lock,
pthread_mutex_trylock,
pthread_mutex_unlock
The
pthread_mutex_init
function conforms to
-p1003.1-96.
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia
|
|