On 16 Oct 2014, at 14:41, Mateusz Guzik <mjgu...@gmail.com> wrote:

> Well, atomic_set can be as simple as v->counter = i; (which btw will
> make it look identical to linux version). This should not give any
> measureable effect unless atomic_set on given var is abused quite a lot.

v->counter = i does not establish a happens-before relationship and so there is 
no guarantee that the write will be visible to other threads until something 
else does establish such a relationship.  The compiler and CPU are both free to 
reorder the store at will, and to elide it.

There is a reason that C11 provides atomic_store and atomic_load operations.  
It sounds like Linux wants the relaxed consistency model here, which *is* 
equivalent to v->counter = i on x86, but *will not be the same* on any 
weakly-ordered architecture (e.g. ARM).

Given that we have a stdatomic.h in the base system, which works with all of 
our supported compilers, please consider using the functionality provided by 
the C standard to solve your exact problem.

David

_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to