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.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: Completely Random Stall
by Anonymous Monk on Jun 12, 2008 at 14:53 UTC
    So how could I detach the threads? Can I do so within the thread it self by calling threads->detach(); from within the thread? ? Also I honestly think you're right, hundred or so threads down the line its just stalling (but the previously running threads ' sub-processes are still running).
      So how could I detach the threads?

      I showed you exactly how to do it above? Change threads->detach; to $thr->detach;.

      detach() is an instance method. That is, you need to call it upon the thread handle you wish to detach. You are currently calling it as a class method, which makes no sense, and if warnings were enabled, would (probably) raise an error.

      Does your OS have a tool that will show you how many threads are running when the stall occurs? Also, are your child processes being cleaned up or are you creating lots of zombies?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Hey BrowserUK, Thank you kindly for your reply, I've looked into it and added it the way you've described. Well the processes that they call end up getting full out exited (with SIGTERM) so I can only assume they do infact clean up afterwards. I'm running fedora core, so ptrace does show me the memory trace, but I'm not sure as to what else I could be using. Any advice would be greatly appreciated. -Kevin