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.

In reply to Re: perl threads and dual core hyper-threading by BrowserUk
in thread perl threads and dual core hyper-threading by JFarr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.