信号量的共识数字是多少? [英] What is the consensus number for semaphores?

查看:117
本文介绍了信号量的共识数字是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我认为)共识编号互斥锁为2.

(I think that) the consensus number for a mutex is 2.

信号量的共识数字是多少(例如pthread_sem_ *中的数字)?

What is the consensus number for semaphores (like in pthread_sem_*)?

条件变量的共识数字是多少(例如pthread_cond _ *)?

What is the consensus number for condition variables (like in pthread_cond_*)?

推荐答案

互斥量的共识数将为1.很明显,互斥量对于单个线程是免费的.从其定义来看,很明显互斥体不再等待两个线程.因此,共识数为> = 1和< 2,因此必须为1.

The consensus number for a mutex would be 1. It's trivially clear that a mutex will be wait-free for a single thread. From its definition, it's also clear that a mutex is no longer wait-free for two threads. The consensus number therefore is >=1 and <2, so it must be 1.

同样,通过停止一个线程而支持另一个线程而工作的其他同步机制也具有共识编号1,因此不能用于构造由2个线程共享的免等待对象.

Likewise, other synchronization mechanisms that work by halting one thread in favor of another also have consensus number 1, and therefore cannot be used to construct a wait-free object shared by 2 threads.

这篇关于信号量的共识数字是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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