Name
pthread_mutex_unlock
- unlock a mutex
Library
libc_r.lib
libpthread.lib
libthr.lib
Synopsis
|
int
pthread_mutex_unlock (pthread_mutex_t *mutex);
|
Return values
If successful,
pthread_mutex_unlock
will return zero, otherwise an error number will be returned to
indicate the error.
Detailed description
If the current thread holds the lock on
mutex,
then the
pthread_mutex_unlock
function unlocks
mutex.
Examples
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int XYZ()
{
int rc;
/* Get the mutex using pthread_mutex_lock() */
if((rc=pthread_mutex_lock(&mutex)) != 0) {
fprintf(stderr,"Error at pthread_mutex_lock(), rc=%d\n",rc);
return -1;
}
/* Release the mutex using pthread_mutex_unlock() */
if((rc=pthread_mutex_unlock(&mutex)) != 0) {
printf("unlock failed \n");
return -1;
}
Errors
The
pthread_mutex_unlock
function will fail if:
[EINVAL]
|
|
The value specified by
mutex
is invalid.
|
[ENOSYS]
|
|
If locking is not supported for this
mutex
kind.
|
See also
pthread_mutex_destroy,
pthread_mutex_init,
pthread_mutex_lock,
pthread_mutex_trylock
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia
|
|