mutex_init(3scl)mutex_init(3scl)NAMEmutex_init - Initializes a mutex.
LIBRARY
SCL Threads Library (libthread.so)
SYNOPSIS
#include <synch.h>
int mutex_init(
mutex_t *mutexp,
int type,
void *arg );
PARAMETERS
Address of the mutex to be initialized. Integer value indicating the
type of mutex required. Possible values are:
for synchronization between threads within a single process (process-
wide scope) for synchronization between threads in different processes
(system-wide scope). Not supported in this release of the Solaris Com‐
patibility Libraries. for synchronization between threads in different
processes robustly (system-wide scope). If a process dies whilst hold‐
ing this mutex, the next owner acquires it with a return-status of
EOWNERDEAD. Not supported in this release of the Solaris Compatibility
Libraries.
Unused. Typically NULL.
DESCRIPTION
This routine initializes a mutex. A mutex is a synchronization object
that allows multiple threads to serialize their access to shared data.
SCL IMPLEMENTATION NOTESmutex_init(3scl) is implemented by calling pthread_mutex_init(3).
mutex_init(3scl) first checks the type parameter. In this implementa‐
tion of the Solaris Compatibility Libraries for Tru64 UNIX, system-wide
(USYNC_PROCESS) and system-wide robust (USYNC_PROCESS_ROBUST) mutexes
are not supported. When an attempt to initialize a mutex to type
USYNC_PROCESS or USYNC_PROCESS_ROBUST is made, the action taken by this
routine is controlled by the environment variable
STL_USYNC_PROCESS_ACTION. The possible values for
STL_USYNC_PROCESS_ACTION, and their meanings, are: log an error message
and abort the process (this is the default action) returns EINVAL
error-status initializes mutex as type USYNC_THREAD
Note that POSIX threads provides several mutex types (see
pthread_mutexattr_settype(3)): default normal recursive error-check
SCL maps Solaris mutexes onto "default" POSIX thread mutexes. This
means that there is typically no notification of programming mistakes
such as: one thread unlocking a mutex which another thread had locked a
thread unlocking a mutex which is not locked
This is consistent with the behaviour of Solaris mutexes.
RETURN VALUES
If an error condition occurs, this routine returns an integer value
indicating the type of error.
Additional error return information may be written to the SCL error
log. Refer to scl_error_log(4scl) for details.
Possible return values are as follows:
Successful completion. The value specified by the type parameter is
invalid for this SCL implementation. Or:
Error EINVAL from pthread_mutex_init(3).
Error other than EINVAL from pthread_mutex_init(3). A message is writ‐
ten to the SCL errorlog which outlines the error-code mapping. Or:
An internal implementation error occurred. Refer to the SCL errorlog
for additional information.
Note: EFAULT is not returned if mutexp is an illegal address. An ille‐
gal address generates a SIGSEGV signal, which by default will abort the
process and generate a core dump.
ERRORS
None.
RELATED INFORMATION
Functions: mutex_destroy(3scl), mutex_lock(3scl), mutex_trylock(3scl),
mutex_unlock(3scl), pthread_mutexattr_settype(3),
pthread_mutex_init(3), scl_intro(3scl), scl_thread_intro(3scl)
Files: scl_error_log(4scl)
Manuals: Solaris Compatibility Libraries User's Guide
mutex_init(3scl)