Open System Services System Calls Reference Manual (G06.25+, H06.03+)
System Functions (n - p) pthread_mutex_lock(2)
NAME
pthread_mutex_lock - Locks an unlocked 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_lock(
pthread_mutex_t *mutex);
PARAMETERS
mutex specifies the mutex to be locked.
DESCRIPTION
This function locks a mutex. The result depends upon the type of mutex:
• If mutex is a fast or nonrecursive mutex, an error is returned if the current owner of the
mutex calls this function in an attempt to lock the mutex a second time.
• If mutex is a recursive mutex, the current owner of the mutex can relock the same mutex
without blocking. The lock count is incremented for each recursive lock within the
thread.
The thread that locks a mutex becomes its current owner and remains its owner until the same
thread unlocks it. This function returns with the mutex in the locked state and the current thread
as the mutex’s current owner.
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.
[EDEADLK] The current thread already owns the mutex.
[EINVAL] The value specified by the mutex parameter is not a valid mutex.
[ENOMEM] There is insufficient memory to lock a statically initialized mutex.
RELATED INFORMATION
Functions: pthread_mutex_destroy(2), pthread_mutex_init(2), pthread_mutex_trylock(2),
pthread_mutex_unlock(2).
STANDARDS CONFORMANCE
This function and recursive mutexes are an extension to the XPG4 Version 2 specification. 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 file spthread.h is an HP exception to the POSIX standard. The return of
[ENOMEM] is an HP extension to the POSIX standard.
527186-003 Hewlett-Packard Company 5−79