Does the MOV x86 instruction implement a C++11 memory_order_release atomic store?

前端 未结 2 1468
别跟我提以往
别跟我提以往 2021-02-09 01:44

According to this https://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html, a released store is implemented as MOV (into memory) on x86 (including x86-64).

Ac

2条回答
  •  醉话见心
    2021-02-09 02:01

    There's memory reordering at run-time (done by CPU) and there's memory reordering at compile-time. Please read Jeff Preshing's article on compile-time reordering (and also great many other good ones on that blog) for further information.

    memory_order_release prevents the compiler from reordering access to data, as well as emitting any necessary fencing or special instructions. In x86 asm, ordinary loads and stores already have acquire / release semantics, so blocking compile-time reordering is sufficient for acq_rel, but not seq_cst.

提交回复
热议问题