pthread_cond_signal()和pthread_cond_wait()
会不会有这样的情况:pthread_cond_signal(cv)先于pthread_cond_wait(cv,mutex)执行,而导致唤醒信号丢失,使得程序阻塞在pthread_cond_wait(cv,mutex)处?
请高手指点,非常感谢!!!O(∩_∩)O~
[解决办法]
该贴到linux专区
是会丢失的
The pthread_cond_broadcast() and pthread_cond_signal() functions shall have no effect if there are no threads currently blocked on cond.
If no thread is blocked on the condition, the subroutine succeeds, but the signalling of the condition is not held. The next thread calling pthread_cond_wait will be blocked.
[解决办法]
去linux社区看看
[解决办法]
当然会了。
之前我做ecos的时候,碰到这个bug,解了几天才搞定。后来分析ecos的源代码,发现他做这个之前,先lock_dsr,基本上等于关中断,禁掉调用。才能工作。
流程是:
关中断
调用可能会产生signal的函数
wait signal
开中断