Open System Services System Calls Reference Manual (G06.25+, H06.03+)

System Functions (n - p) pthread_mutex_unlock(2)
NAME
pthread_mutex_unlock - Unlocks a mutex
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
#include <spthread.h>
int pthread_mutex_unlock(
pthread_mutex_t *mutex);
PARAMETERS
mutex species the mutex to be unlocked.
DESCRIPTION
This function unlocks the mutex specied by the mutex parameter. This function does the fol-
lowing:
If mutex is a fast or nonrecursive mutex: if the mutex is owned by the calling thread, it is
unlocked with no current owner. If the mutex is not locked or is already locked by
another thread, [EPERM] is returned.
If mutex is a recursive mutex: if the mutex is owned by the calling thread, the lock count
is decremented. The mutex remains locked and owned until the lock count reaches 0
(zero). When the lock count reaches 0 (zero), the mutex becomes unlocked with no
current owner.
If one or more threads are waiting to lock the specied mutex and the mutex becomes unlocked,
this function causes one thread to unblock and try to acquire the mutex. The scheduling policy is
used to determine which thread to unblock. A blocked thread is chosen in priority order, using a
rst-in/rst-out (FIFO) algorithm within priorities. Note that the mutex might not be acquired by
the unblocked thread if another running thread attempts to lock the mutex rst.
If a signal is delivered to a thread waiting for a mutex, then upon return from the signal handler,
the thread resumes waiting for the mutex as if it had not been interrupted.
RETURN VALUES
If an error condition occurs, this function returns an integer value indicating the type of error.
Possible return values are:
0 Successful completion.
[EINVAL] The value specied for the mutex parameter is invalid.
[EPERM] The calling thread does not own the mutex.
RELATED INFORMATION
Functions: pthread_mutex_destroy(2), pthread_mutex_init(2), pthread_mutex_lock(2),
pthread_mutex_trylock(2).
STANDARDS CONFORMANCE
This function and recursive mutexes are an extension to the XPG4 Version 2 specication. Inter-
faces documented on this reference page conform to the following industry standards:
IEEE Std 1003.1c-1995, POSIX System Application Program Interface
The use of the header le spthread.h is an HP exception to the POSIX standard.
527186-003 Hewlett-Packard Company 581