|
|
A ``mutual exclusion lock'', or ``mutex'', allows only one thread at any time to access the resource being protected. The lock is acquired by the mutex_lock(3synch) function.
int mutex_lock( mutex_t *mutex );
If the lock is already held by some other thread, the calling thread will block in mutex_lock(3synch).
When the thread holding the lock calls mutex_unlock(3synch), some waiting thread (if any) will be made runnable.
int mutex_unlock( mutex_t *mutex );
The Threads Library does not enforce any notion of ownership of a lock by a thread. The thread unlocking a mutex need not be the same thread that locked the mutex.