DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

_lwp_mutex_lock(2)


_lwp_mutex_lock -- lock a mutex

Synopsis

   #include <synch.h>
   

int _lwp_mutex_lock(lwp_mutex_t *mutex);

Parameters


mutex
pointer to mutex to be locked

Description

_lwp_mutex_lock is used to apply the mutual exclusion lock on a mutex on behalf of the calling lightweight process (LWP). The parameter mutex points to the mutex on which the lock is to be applied.

The mutex must previously have been initialized. A lwp_mutex_t object filled with zeros (for example, by static initialization) is a valid unlocked setting. If the mutex is already locked upon entry, the operation suspends the calling LWP until the mutex becomes available.

From the point of view of the caller, _lwp_mutex_lock is atomic: even if interrupted by a signal or a fork operation, _lwp_mutex_lock will not return until it holds the locked mutex. As a consequence, if _lwp_mutex_lock is interrupted, an error indication such as EINTR is never returned to the caller.

If an LWP waiting on a mutex lock is interrupted by a signal, the signal handler will run, but _lwp_mutex_lock is always restarted so the lock is held on return.

Return values

_lwp_mutex_lock leaves the mutex in the locked state and returns zero to the caller on success, or an error number for failure, as described below.

Errors

If any of the following conditions is detected, _lwp_mutex_lock fails and returns the corresponding value:

EINVAL
The mutual exclusion variable pointed to by mutex is invalid.

EFAULT
The mutex parameter points to an illegal address. (This error may not be detected; a SIGSEGV signal may be posted to the faulting LWP if an illegal address is used.)

Usage

The locks acquired with _lwp_mutex_lock should be released with _lwp_mutex_unlock.

Note that this primitive is used at the LWP level only, and should not be used by threads.

References

_lwp_mutex_unlock(2), _lwp_mutex_trylock(2), mutex_destroy(3synch), mutex_init(3synch), mutex_lock(3synch), mutex_trylock(3synch), mutex_unlock(3synch)

Notices

Lightweight processes (LWPs) are internal interfaces and are subject to change. Their use should be avoided.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004