The problem its related with the random function, whenever I use it the LOCKs appears...

If that's the case, it sounds like your platform has a badly adapted rand function. I don't see any locking involved with the use of rand on my system.

Can we assume that we must avoid rand function whenever using threads?

That would be overkill. In any real workload, calls to rand will likely make up a mere fraction of the total workload, so any contention involved will also likely be minimal for real applications.

In general, drawing conclusions based on extreme testcases--like calling rand in a tight loop concurrrently on 64-threads--is silly. If you ever comeup with a real application that suffers unduly as a result of lock contention calling rand, then consider using an alternative rand implementation. But the likelyhood of you ever encoutering this as a real problem in real code is quite small.


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."

In reply to Re^4: Solaris + UltraSparc T2 + Threads: Avoid LCK's by BrowserUk
in thread Solaris + UltraSparc T2 + Threads: Avoid LCK's by gulden

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.