This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] nptl: optimize cancelstate and canceltype changing


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]