forksafe_mutex_trylock()
QNX SDP8.0C Library ReferenceAPIDeveloper
Attempt to lock a forksafe mutex
Synopsis:
#include <forksafe_mutex.h>
int forksafe_mutex_trylock( forksafe_mutex_t* mutex );
Arguments:
- mutex
 - A pointer to the forksafe_mutex_t object that you want to try to lock.
 
Library:
libc, libforksafe_mutex
There are two versions of the forksafe_mutex_*() functions:
- The functions in libc are declared as weak symbols and use a regular mutex, simply calling the corresponding pthread_mutex_*() functions. Use the -l c option to qcc to link against this library. This library is usually included automatically.
 - The functions in libforksafe_mutex use a forksafe mutex. Use the -l forksafe_mutex option to qcc to link against this library.
 
Description:
The forksafe_mutex_trylock() function attempts to lock the forksafe mutex mutex, but doesn't block the calling thread if the mutex is already locked.
For more information about forksafe mutexes, see
Using fork() in a multithreaded process
in the Processes and Threads
 chapter of Getting Started with the QNX OS.
Returns:
- EOK
 - Success.
 - EAGAIN
 - The mutex couldn't be acquired because the maximum number of recursive locks for mutex has been exceeded.
 - EBUSY
 - The mutex was already locked.
 - EINVAL
 - One of the following occurred:
  
- The mutex was created with a protocol attribute of PTHREAD_PRIO_PROTECT, and the calling thread's priority is higher than the mutex's current priority ceiling.
 - The mutex is invalid, or it has died.
 
 - ENOTRECOVERABLE
 - The mutex is a robust mutex, and the state that it protects isn't recoverable. All you can do with the mutex is destroy it by calling forksafe_mutex_destroy().
 - EOWNERDEAD
 - The mutex is a robust mutex and the process containing the previous owning thread terminated while holding the mutex lock. The calling thread acquires the mutex lock; it's up to the new owner to make the state consistent (see pthread_mutex_consistent()).
 
Classification:
| Safety: | |
|---|---|
| Cancellation point | No | 
| Signal handler | Yes | 
| Thread | Yes | 
Page updated: 
