在内核端设置内存屏障很容易:由于 Linux 内核头文件,宏 mb、wmb、rmb 等始终存在。
如何在用户端做到这一点?
最佳答案
您正在寻找 full memory barrier gcc 的原子内置函数。
请注意我在这里给出的引用资料的详细信息,
The [following] builtins are intended to be compatible with those described in the Intel Itanium Processor-specific Application Binary Interface, section 7.4. As such, they depart from the normal GCC practice of using the “__builtin_” prefix, and further that they are overloaded such that they work on multiple types.
关于c++ - 用户空间中的内存障碍? (Linux,x86-64),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1185063/