C Programming:
What happens when a thread tries to obtain a mutex lock and does not receive it?
Does he fall asleep?
Will the thread wake up when pthread_mutex_unlock (& ββmutex); is called?
Then try to get the lock again?
On the page :
The function blocks the mutex. If the mutex is already locked, the calling thread will block until the mutex is available. pthread_mutex_lock()
pthread_mutex_lock()
So, yes - your thread is blocked until the lock is available and it can receive it.
, , .
pthread_mutex_trylock(pthread_mutex_t *mutex) EBUSY, - , 0, . (, , - )
pthread_mutex_trylock(pthread_mutex_t *mutex)
EBUSY
0
pthread_mutex_lock , , , (). :
pthread_mutex_lock
EAGAIN
EDEADLK
EOWNERDEAD
pthread_mutex_consistent
pthread_mutex_unlock
ENOTRECOVERABLE
, . : (PTHREAD_MUTEX_NORMAL type) , , , , .
PTHREAD_MUTEX_NORMAL
POSIX:
, , .(...)mutex, mutex, pthread_mutex_unlock(), , , .
(...)
mutex, mutex, pthread_mutex_unlock(), , , .
mutex
pthread_mutex_unlock()
"result in" ,
( PTHREAD_MUTEX_RECURSIVE , , .)
PTHREAD_MUTEX_RECURSIVE