Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/p/pthread_mutex_init.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/p/pthread_mutex_init.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/p/pthread_mutex_init.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/p/pthread_mutex_init.html on line 8

pthread_mutex_init()

Initialize mutex

Synopsis:

#include <pthread.h>

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

int pthread_mutex_init(
            pthread_mutex_t* mutex,
            const pthread_mutexattr_t* attr );

Arguments:

mutex
A pointer to the pthread_mutex_t object that you want to initialize.
attr
NULL, or a pointer to a pthread_mutexattr_t object that specifies the attributes that you want to use for the mutex. For more information, see pthread_mutexattr_init().

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The pthread_mutex_init() function initializes the given mutex object, using the attributes specified by the mutex attributes object attr. If attr is NULL, then the mutex is initialized with the default attributes (see pthread_mutexattr_init()). After initialization, the mutex is in an unlocked state.


Caution: You should allocate synchronization objects only in normal memory mappings. On certain processors (e.g. some PPC ones), atomic operations such as calls to pthread_mutex_lock() will cause a fault if the control structure is allocated in uncached memory.

You can initialize a statically allocated mutex with the default attributes by assigning to it the macro PTHREAD_MUTEX_INITIALIZER or PTHREAD_RMUTEX_INITIALIZER (for recursive mutexes).


Note: To destroy a mutex, call pthread_mutex_destroy(). Once you've destroyed a mutex, don't reuse it without reinitializing it by calling pthread_mutex_init().

Returns:

EOK
Success.
EAGAIN
All kernel synchronization objects are in use.
EBUSY
The given mutex was previously initialized and hasn't been destroyed.
EFAULT
A fault occurred when the kernel tried to access mutex or attr.
EINVAL
The value specified by attr is invalid.

Classification:

POSIX 1003.1 THR

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

pthread_mutexattr_init(), pthread_mutex_destroy(), SyncTypeCreate()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/p/pthread_mutex_init.html on line 186

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/p/pthread_mutex_init.html on line 186