Hi,

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
}

-Zenko
-- 
I would rather be exposed to the inconveniences attending too much liberty
than to those attending too small a degree of it.
 - Thomas Jefferson

Reply via email to