in reply to Re^3: Solaris + UltraSparc T2 + Threads: Avoid LCK's
in thread Solaris + UltraSparc T2 + Threads: Avoid LCK's
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Solaris + UltraSparc T2 + Threads: Avoid LCK's
by gulden (Monk) on Apr 24, 2009 at 10:53 UTC | |
by BrowserUk (Patriarch) on Apr 24, 2009 at 12:15 UTC | |
by gulden (Monk) on Apr 24, 2009 at 15:12 UTC | |
by gulden (Monk) on Apr 24, 2009 at 15:23 UTC |