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 | |
|