develooper Front page | perl.ithreads | Postings from May 2009

Re: deadlocking on high cpu usage?

Thread Previous
From:
Jerry D. Hedden
Date:
May 19, 2009 05:23
Subject:
Re: deadlocking on high cpu usage?
Message ID:
1ff86f510905190523p1d0f64bcnb4e07e6c16178991@mail.gmail.com
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.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About