[PATCH v2] nptl: optimize cancelstate and canceltype changing
Richard Henderson
rth@twiddle.net
Sun Jun 15 19:39:00 GMT 2014
On 06/15/2014 04:26 AM, Alexander Fyodorov wrote:
> Changes since v1:
> 1) Added a benchtest for pthread_setcanceltype().
> 2) Defined atomic_write() macro for old SPARC processors.
>
> atomic_write() macro is needed because on some architectures there is no hardware support for atomic compare-and-swap, and it is implemented via spinlock. And writing to variables that are accessed with such compare-and-swap must be done under the same spinlock to avoid the race leading to the lost write.
>
> Dave, could you check my implementation of atomic_write()? I don't have SPARC...
What has lack of compare-and-swap got to do with write?
Certainly sparc stores (of not larger than word size) are atomic. One might
even be able to produce a 64-bit atomic store with std or the fpu; one can't
tell what size you're actually after with this macro.
Certainly, with new enough gcc one ought to use the __atomic_store builtin, but
a plain c store should suffice as a fallback.
r~
More information about the Libc-alpha
mailing list