|
|
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(S) 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(S).
When the thread holding the lock calls mutex_unlock(S), 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.