gpt4 book ai didi

linux - 信号量服务员命令

转载 作者:太空宇宙 更新时间:2023-11-04 09:41:34 25 4
gpt4 key购买 nike

我们想在 Linux 中使用信号量(以及 pthreads)。

我们首先需要知道信号量上的服务员是否正在以 FIFO 方式等待它。这意味着,最后一个等待信号量的人将最后得到它。

谢谢。

最佳答案

来自 http://pubs.opengroup.org/onlinepubs/009696799/functions/sem_post.html 的手册页它不是 FIFO 等待队列:

[PS] [Option Start] If the Process Scheduling option is supported, the thread to be unblocked shall be chosen in a manner appropriate to the scheduling policies and parameters in effect for the blocked threads. In the case of the schedulers SCHED_FIFO and SCHED_RR, the highest priority waiting thread shall be unblocked, and if there is more than one highest priority thread blocked waiting for the semaphore, then the highest priority thread that has been waiting the longest shall be unblocked. If the Process Scheduling option is not defined, the choice of a thread to unblock is unspecified. [Option End]

[SS] [Option Start] If the Process Sporadic Server option is supported, and the scheduling policy is SCHED_SPORADIC, the semantics are as per SCHED_FIFO above. [Option End]

关于linux - 信号量服务员命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20873462/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com