[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

int
pthread_mutex_unlock (
pthread_mutex_t *mutex);

Arguments

mutex
Mutex unlocked.

Description

This routine unlocks a mutex and its behavior varies based on the kind of mutex.

When an owner unlocks a recursive mutex, the lock count is decremented. The mutex remains locked and owned until the count reaches 0. When the lock count reaches 0, or for any other type of mutex, the mutex becomes unlocked with no current owner. If one or more threads are waiting to lock the specified mutex, this routine causes one thread to unblock and try to acquire the mutex. The scheduling policy is used to determine which thread acquires the mutex. For the SCHED_FIFO and SCHED_RR policies, a blocked thread is chosen in priority order, using FIFO within priorities.

The results of calling this routine are unpredictable if the mutex specified in mutex is unlocked. The results of calling this routine are also unpredictable if the mutex specified in mutex is currently owned by a thread other than the calling thread.

Return Values

If an error condition occurs, this routine returns -1 and sets errno to the corresponding error value. Possible return values are as follows:
Return  Error         Description

0 Successful completion. -1 [EINVAL] The value specified by mutex is invalid.



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