mutex_lock(SYNCH)
mutex_lock --
lock a mutex
Synopsis
cc [options] -Kthread file
#include <synch.h>
int mutex_lock(mutex_t *mutex);
Description
mutex_lock locks
the mutual exclusion lock (mutex) pointed to by mutex.
If mutex is locked,
the calling thread is blocked until mutex becomes available.
When mutex_lock returns successfully,
the caller has locked mutex.
Parameters
mutex-
pointer to mutex to be locked
mutex must previously have been initialized,
either by mutex_init, or statically
(see mutex_init(SYNCH)).
From the point of view of the caller,
mutex_lock is atomic:
even if interrupted by a signal or forkall (see
fork(S)),
mutex_lock will not return
until it holds the locked mutex.
As a consequence, if mutex_lock is interrupted,
an error indication such as EINTR is never returned to the caller.
Usage
Mutexes acquired with mutex_lock should be released
with mutex_unlock.
Return values
mutex_lock returns zero for success
and an error number for failure.
Errors
If the following condition is detected,
mutex_lock returns the corresponding value:
EINVAL-
invalid argument specified
Warnings
If a thread exits while holding a mutex,
the mutex will not be unlocked,
and other threads waiting for the mutex will wait forever.
Similarly, if a process exits while holding a USYNC_PROCESS mutex,
the mutex will not be unlocked,
and other processes or threads waiting for the mutex will wait forever.
References
fork(S),
Intro(SYNCH),
mutex(SYNCH),
mutex_destroy(SYNCH),
mutex_init(SYNCH),
mutex_trylock(SYNCH),
mutex_unlock(SYNCH)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005