How to guarantee 64-bit writes are atomic?

前端 未结 8 1318
不知归路
不知归路 2020-12-23 22:34

When can 64-bit writes be guaranteed to be atomic, when programming in C on an Intel x86-based platform (in particular, an Intel-based Mac running MacOSX 10.4 using the Inte

8条回答
  •  不知归路
    2020-12-23 23:08

    GCC has intrinsics for atomic operations; I suspect you can do similar with other compilers, too. Never rely on the compiler for atomic operations; optimization will almost certainly run the risk of making even obviously atomic operations into non-atomic ones unless you explicitly tell the compiler not to do so.

提交回复
热议问题