initialize a mutex
cc [options] -Kthread file
int mutex_init(mutex_t *mutex, int type, void *arg);
mutex_init initializes the mutual exclusion lock (mutex)
pointed to by mutex
to be of type type and in the unlocked state.
Once initialized, the mutex can be used any number of times without
pointer to mutex to be initialized
USYNC_THREAD or USYNC_PROCESS
NULL (reserved for future use)
mutex points to the mutex to be initialized.
type can be set to one of the following values:
initialize the mutex for threads within the current process
initialize the mutex for threads across processes
arg should be set to NULL.
It is not currently used, but is reserved for future use.
Static mutex initialization
A mutex can be initialized statically
if its storage is zero-filled.
In this case, the mutex is of type USYNC_THREAD,
and mutex_init need not be called.
mutex_init returns zero for success
and an error number for failure.
If the following condition is detected,
the contents of mutex are unchanged and
mutex_init returns the corresponding value:
invalid type argument specified
mutex_init does not examine the mutex argument
before initializing it.
If mutex_init is called more than once for the same mutex,
it will overwrite its state.
It is the user's responsibility to ensure that mutex_init
is only called once for each mutex.
Operations on locks initialized with
mutex_init are not recursive--a thread can deadlock if
it attempts to relock a mutex that it already has locked.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004