core.stdc.stdatomic
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Tue Nov 14 08:58:34 UTC 2023
On 14/11/2023 9:35 PM, Walter Bright wrote:
> The fence instructions are supported by DMD's inline assembler, so they
> can be done, too, as simple functions.
>
> Why is this a write-off?
From C11 spec for ``atomic_signal_fence``:
NOTE 2 Compiler optimizations and reorderings of loads and stores are
inhibited in the same way as with
atomic_thread_fence, but the hardware fence instructions that
atomic_thread_fence would
have inserted are not emitted.
In other words no instructions emitted, it does not map to an x86
instruction.
I've said this before, dmd is a write off for lock-free concurrent data
structures. Having ANY extra functions in the call stack can throw off
the timing and end in segfaults. It MUST be inlined! This will be true
of any use case for atomics that is beyond that of reference counting.
More information about the Digitalmars-d
mailing list