in reply to Re^4: baton passing threads and cond_signal
in thread baton passing threads and cond_signal
Say you've got 10 threads waiting on the same condition like in your code. When you broadcast, you'll wake up all threads one after another. But in the mean time, one of the threads (the one who's thread id matches the baton) will broadcast. So now you're waking up all threads again while you're not done waking up the rest of the threads, and so on. That might grind the program to a halt fairly quickly if the broadcasts do not terminate when a new broadcast is done on the same condition variable.
Now I'm not sure if that's what happens. If it is, I suspect you'd see the process taking up a lot of CPU time, while if the problem is some kind of deadlock, you'd see the process taking essentially no CPU time at all.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: baton passing threads and cond_signal
by Anonymous Monk on Aug 22, 2007 at 15:50 UTC | |
by ikegami (Patriarch) on Aug 22, 2007 at 16:08 UTC | |
by Anonymous Monk on Aug 22, 2007 at 16:25 UTC | |
by ikegami (Patriarch) on Aug 22, 2007 at 16:34 UTC | |
by Anonymous Monk on Aug 22, 2007 at 16:47 UTC | |
|