core.stdc.stdatomic
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Wed Nov 15 10:26:32 UTC 2023
On 15/11/2023 10:55 PM, claptrap wrote:
> That doesnt make any sense, the whole point of CAS is that it is atomic,
> immediately after it has completed you have no guarantees anyway, what
> difference does it make if it's wrapped in a function call?
I understand that it seems like it does not make sense. Lock-free
concurrent data structures are a highly advanced topic, that very few
people in the world today can implement successfully. About the only
people who are qualified to touch them for production software would be
kernel developers for a specific cpu family.
They rely quite heavily on the premise that atomic operations happen
immediately in the codegen and then based upon the results do set
actions in response. This is timing based it has to be preciese or they
will interfere with each other. You do not have much lee-way before you
start getting segfaults.
I only ever saw partial success with ldc after seven months of
researching them. For obvious reasons I do not recommend people going
down this particular path of study, because you are going to get burned
pretty badly guaranteed.
Regardless compilers like gcc have intrinsics for all of stdatomic. We
need to be matching it otherwise what D supports will not line up with
what the system C compiler can offer in terms of use cases.
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
More information about the Digitalmars-d
mailing list