什么是多线程等待`pthread_mutex_lock()的'唤醒命令? [英] What is the `pthread_mutex_lock()` wake order with multiple threads waiting?

查看:487
本文介绍了什么是多线程等待`pthread_mutex_lock()的'唤醒命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假如我有多个线程阻塞调用 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 called pthread_mutex_lock() get the lock? That is, are calls to pthread_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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆