in reply to Re^5: Threads sharing global variable
in thread Threads sharing global variable
Completely bogus analysis.
You called it. And you are right. Your analysis is completely bogus.
If your design is to lock-step all your threads so that only one thread can be doing *anything* at any given moment, then why are you using threads?
Better to simply call the appropriate functions serially in the correct order in a single thread; and avoid not just the overhead of threading & synching, but also the non-determanistic delays between those serial steps caused by requiring the scheduler to orchestrate the transfer of control between them; and also avoid competing with every other thread; not just those in your process, but in the entire system.
The OPs example only makes sense if, between the synchronisation points, each thread has other work to be doing independently, and at different iteration rates. Ie. each synchronising thread also does other stuff in the loop between cond_waits(). But with ikegami's cockeyed design, that simply isn't possible.
* as in, it's nonsense!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Threads sharing global variable
by ikegami (Patriarch) on Mar 09, 2016 at 13:44 UTC |