Memory barriers in userspace? (Linux, x86-64)
问题 It is easy to set memory barriers on the kernel side: the macros mb, wmb, rmb, etc. are always in place thanks to the Linux kernel headers. How to accomplish this on the user side? 回答1: Posix defines a number of functions as acting as memory barriers. Memory locations must not be concurrently accessed; to prevent this, use synchronization - and that synchronization will also work as a barrier. 回答2: You are looking for the full memory barrier atomic builtins of gcc. Please note the detail on