[riot-notifications] [RIOT-OS/RIOT] sys: Added simple memory barrier API (#11438)

Kaspar Schleiser notifications at github.com
Wed Apr 24 17:02:41 CEST 2019

kaspar030 commented on this pull request.

> + * @brief       Memory Barriers
+ *
+ * # FAQ
+ * ## What are Memory Barriers
+ * Memory barriers suppress specific kinds optimization performed by the
+ * compiler or (in case of out-of-order CPUs) CPUs, depending on the barrier.
+ * This will most likely result in slower program execution and, thus, is in
+ * general unwanted. However, under specific circumstances, optimization can
+ * prevent correct execution.
+ *
+ * ## Why can't I use `volatile` instead
+ * Memory accesses to `volatile` can be viewed as an alternative to
+ * @ref compiler_barrier, but only in regard to other accesses to `volatile`
+ * variables. (Some compilers do not reorder memory accesses to non-`volatile`s
+ * across accesses to `volatile`s as well, but not all compilers do so.)
+ * Resorting to mark all variables as `volatile` to enforce the correct order

having one variable volatile enforces load/store to that one variable to be issued (WRT volatile rules). A memory barrier forces the compiler to forget everything it knows about all variables in the current scope. Doesn't that possibly lead to more reloads than necessary?

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190424/95062f28/attachment-0001.html>

More information about the notifications mailing list