pthread_cond_wait will relock the mutex
2011-05-05 18:05
323 查看
Quoting APUE2:
The mutex passed to pthread_cond_wait protects the condition. The caller passes it locked to the function, which then atomically places the calling thread on the list of threads waiting for the condition and unlocks the mutex. This closes the window between the time that the condition is checked and the time that the thread goes to sleep waiting for the condition to change, so that the thread doesn't miss a change in the condition. When pthread_cond_wait returns, the mutex is again locked.
The mutex passed to pthread_cond_wait protects the condition. The caller passes it locked to the function, which then atomically places the calling thread on the list of threads waiting for the condition and unlocks the mutex. This closes the window between the time that the condition is checked and the time that the thread goes to sleep waiting for the condition to change, so that the thread doesn't miss a change in the condition. When pthread_cond_wait returns, the mutex is again locked.
相关文章推荐
- int pthread_cond_wait(pthread_cond_t *restrict cond, pthread_mutex_t *restric mutex)
- 通过pthread_mutex_lock和pthread_cond_wait实现生产消费模式,并且生产一次消费一次
- pthread_cond_wait pthread_cond_broadcast pthread_mutex_lock
- 线程同步之 pthread_cond_wait 和pthread_mutex
- 条件锁(条件Mutex)pthread_cond_wait、pthread_cond_signal、pthread_cond_broadcast的使用[转]
- 来自知乎的pthread_cond_wait为什么总是带着mutex
- 一段使用 mutex 和 条件变量 pthread_cond_wait 的例子
- pthread_mutex_t,pthread_cond_wait
- 互斥锁pthread_mutex_t与pthread_cond_wait的使用
- 浅谈pthread_cond_wait(pthread_cond_t *cond,pthread_mutex_t *mutex)
- man pthread_mutex_lock,man pthread_cond_wait没文档的解决办法
- 条件锁(条件Mutex)pthread_cond_wait、pthread_cond_signal、pthread_cond_broadcast的使用
- 条件变量pthread_cond_wait(&g_cond,&mutex);
- 条件锁(条件Mutex)pthread_cond_wait、pthread_cond_signal、pthread_cond_broadcast的使用
- linux 多线程 pthread_cond_wait(&cond,&mutex)理解
- SB了,pthread_cond_wait(),在等待的时候会解锁(阻塞之后,解锁mutex给别的线程),唤醒后加锁,
- 为什么pthread_cond_wait需要传递mutex参数
- pthread_cond_wait与mutex、while
- 为什么pthread_cond_wait需要传递mutex参数
- 互斥量、条件变量与pthread_cond_wait()函数的使用,详解