Initialize a forksafe mutex
#include <forksafe_mutex.h> forksafe_mutex_t mutex = FORKSAFE_MUTEX_INITIALIZER; int forksafe_mutex_init( forksafe_mutex_t* mutex, const pthread_mutexattr_t* attr );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The forksafe_mutex_init() function initializes the given forksafe 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.
You can initialize a statically allocated mutex with the default attributes by assigning to it the macro FORKSAFE_MUTEX_INITIALIZER or FORKSAFE_RMUTEX_INITIALIZER (for recursive mutexes).
For more information about forksafe mutexes, see Using fork() in a multithreaded process in the Processes and Threads chapter of Getting Started with QNX Neutrino.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |