Hardware Reference
In-Depth Information
Error
Description
Mutex is locked or in use in conjunction with a pthread_cond_wait(3) or
pthread_cond_timedwait(3) .
EBUSY
EINVAL
The value specified by mutex is invalid.
pthread_mutex_lock(3)
When a thread needs exclusive access to a resource, it must lock the resource's mutex. As
long as the cooperating threads follow the same procedure of locking first, they cannot
both access the shared object at the same time.
int pthread_mutex_lock(pthread_mutex_t
mutex);
mutex : A pointer to the mutex to lock.
returns : Returns zero if the mutex was successfully locked;
otherwise, an error code is returned (not in errno ).
Error
Description
EINVAL
The mutex was created with the protocol attribute having the value
PTHREAD_PRIO_PROTECT, and the calling thread's priority is higher
than the mutex's current priority ceiling. Or the value specified by the
mutex does not refer to an initialized mutex object.
EAGAIN
Maximum number of recursive locks for mutex has been exceeded.
EDEADLK
The current thread already owns the mutex.
The following shows the function being called:
pthread_mutex_t mutex;
int rc;
...
rc = pthread_mutex_lock(&mutex);
pthread_mutex_unlock(3)
When exclusive access to a resource is no longer required, the mutex is unlocked:
int pthread_mutex_unlock(pthread_mutex_t
mutex);
mutex : A pointer to the mutex to be unlocked.
returns : Returns zero if the mutex was unlocked successfully;
otherwise, an error code is returned (not in errno ).
 
 
Search WWH ::




Custom Search