Is it safe to assume read/write of double value is atomic in a 64-bit machine with c/c++ programming
I have two process sharing a memory. process 1 is in c, which is the writer of double value and process 2 in c++ is reader of this value.
Is it safe to assume read/write of double value is atomic in a 64-bit machine with c/c++ programming
I have two process sharing a memory. process 1 is in c, which is the writer of double value and process 2 in c++ is reader of this value.
No, if you want atomic operations use std::atomic<double>
C11
introduced atomic types: C11 Atomics
With any luck, C++ also adopted these for portability. If not, you may have to rely on compiler extensions: GCC Atomic Builtins
Or simply locking with a mutex.