Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

pthread_mutex_unlock(2) OSS System Calls Reference Manual
NAME
pthread_mutex_unlock - Unlocks a mutex
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
32-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/zputdll
64-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/yputdll
H-series and J-series OSS processes that use the Standard POSIX Threads library:
/G/system/zdllnnn/zsptdll
SYNOPSIS
#include <pthread.h> | #include <spthread.h>
/* pthread.h is required to use POSIX User Thread Model library */
/* spthread.h is required to use Standard POSIX Threads library */
int pthread_mutex_unlock(
pthread_mutex_t *mutex);
PARAMETERS
mutex Specifies the mutex to be unlocked.
DESCRIPTION
This function unlocks the mutex specified 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 specified 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
first-in/first-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 first.
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.
On systems running H06.21 or later H-series RVUs or J06.10 or later J-series RVUs, you can use
either the POSIX User Thread Model library or the Standard POSIX Threads library for threaded
applications.
To use this function in a threaded application that uses the POSIX User Thread Model library on
systems running H06.21 or later RVUs or J06.10 or later RVUs, you must perform all of the fol-
lowing tasks:
Include the pthread.h header file in the application.
Compile the application using the _PUT_MODEL_ feature test macro or equivalent
compiler command option.
5160 Hewlett-Packard Company 527186-023