[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


pthread_mutex_unlock

Unlocks a mutex.

Syntax

pthread_mutex_unlock(
                     mutex );
 


Argument Data Type Access

mutex opaque pthread_mutex_t read


C Binding

#include 

int pthread_mutex_unlock ( pthread_mutex_t *mutex);

Arguments

mutex
Mutex to be unlocked.

Description

This routine unlocks a mutex.

The following describes the varied behavior of this routine:

If one or more threads are waiting to lock the specified mutex, and the mutex becomes unlocked, this routine causes one thread to unblock and try to acquire the mutex. The scheduling policy is used to determine which thread to unblock. For the SCHED_FIFO and SCHED_ RR policies, a blocked thread is chosen in priority order, using first-in/first-out within priorities. Note that the mutex may not be acquired by the awakened thread if any other running thread attempts to lock the mutex first.

On Digital Unix, if a signal is delivered to a thread waiting for a mutex, upon return from the signal handler, the thread resumes waiting for the mutex as if it was not interrupted.

Return Values

If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:
Return        Description

0 Successful completion. [EINVAL] The value specified for mutex is invalid. [EPERM] The calling thread does not own the mutex.


Associated Routines

   pthread_mutexattr_settype_np
   pthread_mutex_destroy
   pthread_mutex_init
   pthread_mutex_lock
   pthread_mutex_trylock
   pthread_unlock_global_np



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]