Zenko Klapko Jr. wrote: > I have a perl script that gathers some data initially in the main thread, > then farms out work to helper threads. I have two shared variables, each > controlling access to a separate library. Never do I lock() both in the same > sub-block, and even if I did I would make sure I did it in the same order. > Under low cpu usage (when the script runs by itself) everything works out. > Under high cpu usage (run yes) the perl script appears to deadlock. I took a > look at the script under strace and its stuck on futex. I'm wondering if my > code is to blame and the deadlock only appears under high cpu usage. Any > help (pointing out my terrible code counts) is appreciated! > > Main Thread->GathersInfo()->Launch 5 Worker Threads->End > > WorkerThreadSub() > { > > if($possiblyTrue) > {lock($a) > launch thread with library > join() > } > > { lock($b) > launch thread with other library > join() > } > > if($possiblyTrue) > {lock($a) > launch thread with library > join() > } > ...stuff... > #end WorkerThread > }
This pseudo-code is insufficient to understand the problem. Please send a working example that we can test with. Thanks.