gpt4 book ai didi

c - PTHREAD_COND_INITIALIZER - 函数 pthread_cond_wait() 分支到慢速路径

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

发件人:http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/apis/users_75.htm

Static initialization using the PTHREAD_COND_INITIALIZER does not immediately initialize the mutex.

Instead, on first use, the functions pthread_cond_wait(), pthread_cond_timedwait(), pthread_cond_signal(), and pthread_cond_broadcast() branch into a slow path and cause the initialization of the condition.

Due to this delayed initialization, the results of calling pthread_cond_destroy() on a condition variable that was initialized using static initialization and not used yet cause pthread_cond_destroy() to fail with teh EINVAL error.

当他们说“分支到一条慢路”是什么意思?
那里发生了什么?

最佳答案

branch into a slow path and cause the initialization of the condition.

分支到“慢”路径可能意味着调用额外的代码来执行(一次性)条件变量的第一次使用的初始化。

由于这种情况只发生一次,第一次使用该条件比后续调用花费的时间更长,因此它比任何后续使用都“慢”。

关于c - PTHREAD_COND_INITIALIZER - 函数 pthread_cond_wait() 分支到慢速路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31603257/

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