由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 请教一个线程同步的问题。
相关主题
请教一个linux下面的多线程semaphore的问题。这样的deadlock如何debug?
HELP:这个死锁是怎么发生的?关于multi thread
重复利用threads的问题多个thread的通信
thread, semaphore, 问题。精华区翻出来的MS老题,thread safe
Java的服务器一般运行几个线程比较合适?多线程 编程,process 和 thread 的一些问题。
连续release mutex/semphore 2次有什么问题吗?how can python code wait for signal from a c code program ? (转载)
计算机供电不稳定会影响程序/线程运行吗?pthread mutex能不能用与thread和process之间
编程题又一道java multi-threading project怎么确定它没有deadlock, race condition?
相关话题的讨论汇总
话题: thread话题: status话题: true话题: semaphore话题: wait
进入Programming版参与讨论
1 (共1页)
d**d
发帖数: 389
1
两个线程A 和 B,现有一个信号量s。
thread model like this
s=semaphore_create(1);
in thread A
semaphore_wait(s);
{
do_some_thing_here;
wait until STATUS in thread B is TRUE;
continue_do_something;
}
semaphore_signal(s);
in thread B:
semaphore_wait(s);
{
do_some_thing_here;
set STATUS to TRUE;
continue_do_something;
}
semaphore_signal(s);
问题是:
in thread A "wait until STATUS in thread B is TRUE;", 如果用另外一个新的信号量,那么肯定是死锁。请问有没有什么好的解决办法让thread A一直等到STATUS被thread B设成 TRUE。
非常感谢!!!
S****z
发帖数: 666
2
s=2?

信号量,那么肯定是死锁。请问有没有什么好的解决办法让thread A一直等到STATUS被
thread B设成 TRUE。

【在 d**d 的大作中提到】
: 两个线程A 和 B,现有一个信号量s。
: thread model like this
: s=semaphore_create(1);
: in thread A
: semaphore_wait(s);
: {
: do_some_thing_here;
: wait until STATUS in thread B is TRUE;
: continue_do_something;
: }

j******n
发帖数: 271
3
Try condition variable.
1 (共1页)
进入Programming版参与讨论
相关主题
java multi-threading project怎么确定它没有deadlock, race condition?Java的服务器一般运行几个线程比较合适?
Thread Priority 设为最高--窗口最小化时好像并不优先啊?连续release mutex/semphore 2次有什么问题吗?
怎么 kill 一个 thread 啊计算机供电不稳定会影响程序/线程运行吗?
[合集] 为什么多个线程生成的随机数是一样的?编程题又一道
请教一个linux下面的多线程semaphore的问题。这样的deadlock如何debug?
HELP:这个死锁是怎么发生的?关于multi thread
重复利用threads的问题多个thread的通信
thread, semaphore, 问题。精华区翻出来的MS老题,thread safe
相关话题的讨论汇总
话题: thread话题: status话题: true话题: semaphore话题: wait