pthread_mutex_lock(3-thr) pthread_mutex_lock(3-thr)
NAME
pthreadmutexlock - locks an unlocked mutex
SYNOPSIS
#include <pthread.h>
int pthreadmutexlock(pthreadmutext *mutex);
PARAMETERS
mutex Mutex that is locked.
DESCRIPTION
The pthreadmutexlock() routine locks a mutex. If the mutex is locked
when a thread calls this routine, the thread waits for the mutex to
become available.
The thread that has locked a mutex becomes its current owner and
remains the owner until the same thread has unlocked it. This routine
returns with the mutex in the locked state and with the current thread
as the mutex's current owner.
If you specified a fast mutex in a call to
pthreadmutexattrsetkindnp(), a deadlock can result if the current
owner of a mutex calls this routine in an attempt to lock the mutex a
second time. If you specified a recursive mutex in a call to
pthreadmutexattrsetkindnp(), the current owner of a mutex can
relock the same mutex without blocking. If you specify a nonrecursive
mutex in a call to pthreadmutexattrsetkindnp(), an error is
returned and the thread does not block if the current owner of a mutex
calls this routine in an attempt to lock the mutex a second time.
The preemption of a lower-priority thread that locks a mutex possibly
results in the indefinite blocking of higher-priority threads waiting
for the same mutex. The execution of the waiting higher-priority
threads is blocked for as long as there is a sufficient number of
runnable threads of any priority between the lower-priority and
higher-priority values. Priority inversion occurs when any resource is
shared between threads with different priorities.
RETURN VALUES
If the function fails, errno may be set to one of the following
values:
EINVAL The value specified by mutex is invalid.
EDEADLK A deadlock condition is detected.
SEE ALSO
pthreadmutexdestroy(3-thr), pthreadmutexinit(3-thr),
pthreadmutextrylock(3-thr), pthreadmutexunlock(3-thr),
pthreadmutexattrsetkindnp(3-thr).
Page 1 Reliant UNIX 5.44 Printed 11/98