This week there are three weddings at our departments. Oh, Olympic year!!!
pthread_cond_wait atomically unlocks the mutex (as per pthread_unlock_mutex) and waits for the condition variable cond to be signaled. The thread execution
is suspended and does not consume any CPU time until the condition variable is signaled. The mutex must be locked by the calling thread on entrance to pthread_cond_wait.
Before returning to the calling thread, pthread_cond_wait re-acquires mutex (as per pthread_lock_mutex).
Unlocking the mutex and suspending on the condition variable is done atomically. Thus, if all threads always acquire the mutex before signaling the condition,
this guarantees that the condition cannot be signaled (and thus ignored) between the time a thread locks the mutex and the time it waits on the condition variable.
2008 April 11th Friday (四月 十一日 金曜日)
最新推荐文章于 2018-10-26 10:25:51 发布
本文探讨了线程在操作系统中的条件等待原子操作原理,包括条件变量的使用、锁的管理以及线程间的同步机制。
646

被折叠的 条评论
为什么被折叠?



