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.
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |