[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Test atomic operations on SPARC 32-bit



Hi Romain,

> As mentioned by someone else, v7 and v8 do not have them as hardware
> instruction. They were introduced in v9 and its 32 bits sibling, v8+.
As I wrote, yep v8 => I need to emulate implementation.
 
> You can emulate them in many ways, including with a trivial global
> lock using the existing test-and-set instruction.
> I did that a while ago for some recompilation in S7 and S8:
> <http://www.dolbeau.name/dolbeau/files/libsparcatomic-0.3.0.tgz>
Nice, thanks a lot! I might use kernel implementation, but this is handy.
I'll see, what will be easier to port to my specific use-case.

> Beware that it's not a universal solution.
> 
> 1) The lock variable is defined in the library, so it's not shared
> between processes. Atomic won't work between processes in shared
> memory such as SysV shmem, only for threads. Going multi-process
> transparently (w/o changing the function signature) is non-trivial.
I need threads only, no shmem...

> 2) The lock variable is one big contention point that will slow things
> down, by forcing mutual exclusion for all atomic accesses including
> those to different variables. In theory it could be replaced by an
> array of variables (in different cache lines) using some sort of hash
> function based on the address of the protected variable. If that
> matters... use v8+ hardware instead would be my advice :-) v7 and v8
> are not suitable for modern parallelism.
It looks to me that this is used in kernel (if I understand the code correctly).

Kind regards,
Petr


Reply to: