rmutex_lock(3synch)


rmutex_lock -- lock a recursive mutex

Synopsis

   cc [options] -Kthread file
   

#include <synch.h>

int rmutex_lock(rmutex_t *rmutex);

Description

rmutex_lock locks the recursive mutual exclusion lock (rmutex) pointed to by rmutex. If rmutex is locked by another thread, the calling thread is blocked until rmutex becomes available. When rmutex_lock returns successfully, the caller has locked rmutex.

If rmutex is already locked by the calling thread, the recursive depth is incremented and control is returned to the caller, as if the lock had just been acquired.

rmutex must previously have been initialized (see rmutex_init(3synch)).

Parameters


rmutex
pointer to recursive mutex to be locked
From the point of view of the caller, rmutex_lock is atomic: even if interrupted by a signal or forkall [see fork(2)], rmutex_lock will not return until the lock is held.

Usage

The locks acquired with rmutex_lock should be released with rmutex_unlock.

Return values

rmutex_lock returns zero for success and an error number for failure.

Errors

If the following condition is detected, rmutex_lock fails and returns the corresponding value:

EINVAL
invalid argument specified

Warnings

If a thread exits while holding an rmutex, the rmutex will not be unlocked, and other threads waiting for the rmutex will wait forever. Similarly, if a process exits while holding a USYNC_PROCESS rmutex, the rmutex will not be unlocked, and other processes or threads waiting for the rmutex will wait forever.

References

fork(2), Intro(3synch), mutex(3synch), rmutex(3synch), rmutex_destroy(3synch), rmutex_init(3synch), rmutex_trylock(3synch), rmutex_unlock(3synch)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004