On 07/22/2015 01:19 AM, Sebastian Kuzminsky wrote: > I don't see any memory barrier functions in stdatomic.h.
You don't really need a full barrier. Atomic memory access is just a small part of stdatomic.h. The important part is the new memory model. See the following functions: http://en.cppreference.com/w/c/atomic/atomic_load http://en.cppreference.com/w/c/atomic/atomic_store In Jeff's example of using a flag to indicate new data available, the flag should probably be of type atomic_bool and should be written with atomic_store and read with atomic_load. I THINK that you don't actually need full sequential consistency. Use atomic_load_explicit with memory_order_acquire and atomic_store_explicit with memory_order_release. This will give you just as much protection as you need with as little cost as can be achieved on your architecture. I've mentioned these videos from Herb Sutter before, but it you have an extra 3 hours they can be enlightening. http://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Herb-Sutter-atomic-Weapons-1-of-2 http://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Herb-Sutter-atomic-Weapons-2-of-2 It is a C++11 talk, but most of it applies to C11 as well. -- Chris Lesiak Principal Design Engineer, Software LI-COR, Inc. [email protected] Any opinions expressed are those of the author and do not necessarily represent those of his employer. ------------------------------------------------------------------------------ _______________________________________________ Emc-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-developers
