本文介绍了pthread_cond_signal()仅释放一个线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pthread_cond_signal是否完全取消阻塞一个线程?如果没有,它将释放多个线程怎么办?规格说明如下:

Does pthread_cond_signal unblock exactly one thread? If not, what will be the case it releases more than one thread? The specification says as follows:

推荐答案

pthreads规范允许实现中的虚假唤醒".例如,请参见pthread_cond_signalpthread_cond_wait的假设实现,规范,仅允许这种情况.

The pthreads specification allows for "spurious wakeups" in an implementation. See, for example, the hypothetical implementation of pthread_cond_signal and pthread_cond_wait sketched in the specification that allows for just this condition.

伪唤醒的可能性是为什么总是将某些谓词与条件相关联,并在唤醒时检查该谓词的原因.

The possibility of spurious wakeups is why one always associates some predicate with a condition, and checks that predicate upon wakeup.

这篇关于pthread_cond_signal()仅释放一个线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 05:54