in reply to Completely Random Stall
I suspect, but cannot confirm that if you were to add strict and warnings and clean up all the messages they produce, then you would probably go a long way to fixing your problem.
One definite error is that you are never cleaning up your threads, because this code make no sense whatsoever:
$thr = threads->new(\&initiator, @list5); $thr = threads->detach;
That should probably be,
$thr = threads->new(\&initiator, @list5); $thr->detach;
Which means none of your threads are being discarded when they complete, so you will eventually run of of threads. How quickly may depend upon the limits your of your OS, or of some internal details of the Perl implementation.
But fixing that may not itself be sufficient to fix your problem because $thr, along most everything else, is a global var. This may be benign, but since I never program that way, I have no notion as to the implications, so it gives me cause for concern.
Also, as presented, there is no purpose in running manager() (once) as a thread, and then having your main thread go into a do nothing loop. You can replace these two lines:
$thr1 = threads->new(\&manager); while (1){sleep(1);}
with:
manager();
And your program will run exactly as it does now, but with one less thread doing nothing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Completely Random Stall
by Anonymous Monk on Jun 12, 2008 at 14:53 UTC | |
by BrowserUk (Patriarch) on Jun 12, 2008 at 15:07 UTC | |
by expresspotato (Beadle) on Jun 12, 2008 at 18:00 UTC | |
by BrowserUk (Patriarch) on Jun 12, 2008 at 22:50 UTC |