什么是多线程等待`pthread_mutex_lock()的'唤醒命令? [英] What is the `pthread_mutex_lock()` wake order with multiple threads waiting?
问题描述
假如我有多个线程阻塞调用 pthread_mutex_lock()的
。如果互斥锁变为可用,这是否叫()
第一个线程调用pthread_mutex_lock获得锁?也就是说,是 FIFO顺序pthread_mutex_lock()的
电话?如果不是,那么,如果有的话,以便它们在?谢谢!
在互斥变为可用,这是否叫
第一个线程调用pthread_mutex_lock()
获得锁?
块引用>没有。一个等待的线程获得锁,但其中一个得到它并不确定。
FIFO的顺序?
块引用>FIFO互斥,而已经是一个模式。请参见在实施的pthreads一个FIFO互斥
Suppose I have multiple threads blocking on a call to
pthread_mutex_lock()
. When the mutex becomes available, does the first thread that calledpthread_mutex_lock()
get the lock? That is, are calls topthread_mutex_lock()
in FIFO order? If not, what, if any, order are they in? Thanks!解决方案When the mutex becomes available, does the first thread that called
pthread_mutex_lock()
get the lock?No. One of the waiting threads gets a lock, but which one gets it is not determined.
FIFO order?
FIFO mutex is rather a pattern already. See Implementing a FIFO mutex in pthreads
这篇关于什么是多线程等待`pthread_mutex_lock()的'唤醒命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!