This probably won't affect the outcome of your tests, which seem backward to me, but without seeing what you are doing in locateSysHost_Parallel() it's not really possible to comment on what might or might not be the causes of the symptoms you are seeing beyond liz's observation about your second example serialising the threads, but this line from your first snippet:
(threads->list)[0]->join while threads->list;
is a horribly inefficient way to do things.
The first call to threads->list walks a linked list, constructing an object for each thread, expands the stack to accomodate it, and then pushes it on. It the returns to your code, where you promptly discard all but the first of them and call join on it.
The second call repeats the process of walking the linked list, but because of the scalar context, skips building the list and just accumulates a count and returns it to you. Which you then promptly discard by turning the count into a boolean.
You then repeat the above two steps for each thread running. That's is a O(2n!) (factorial) O(n*(n-1)) process where n is the number of threads. The following is simply O(n).
$_->join for threads->list;
and the scripts did not even get off the ground. We had our first print statement execute, then the threads went into lala land.
"did not get off the ground" and "lala land" are not very useful descriptions for attempting to diagnose a problem from :). A cut down script that demonstrates the problem would be much more useful.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|