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

Marian Buschsieweke notifications at github.com
Wed Apr 24 17:05:08 CEST 2019


maribu commented on this pull request.



> +
+/**
+ * @defgroup    sys_barriers Memory Barriers
+ * @ingroup     sys
+ * @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

What the Linux guys do is writing a helper function-like macro that casts the pointer to a pointer to `volatile` memory of the same type and performs the memory access. This will prevent optimization only for that very access that needs to be done in a properly sized store

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11438#discussion_r278173640
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190424/2235765c/attachment.html>


More information about the notifications mailing list