Memory barriers in userspace? (Linux, x86-64)

后端 未结 8 1776
无人及你
无人及你 2021-01-30 18:15

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 th

8条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 19:00

    Use libatomic_ops. http://www.hpl.hp.com/research/linux/atomic_ops/

    It's not compiler-specific, and less buggy than the GCC stuff. It's not a giganto-library that provides tons of functionality you don't care about. It just provides atomic operations. Also, it's portable to different CPU architectures.

提交回复
热议问题