Answer by Peter Cordes for Is struct assignment atomic in C/C++?
Do you need to atomically snapshot all the struct members? Or do you just need shared read/write access to separate members separately? The latter is a lot easier, see below.C11 stdatomic and C++11...
View ArticleAnswer by sehe for Is struct assignment atomic in C/C++?
No it isn't.That is actually a property of the CPU architecture in relation to the memory layout of struckYou could use the 'atomic pointer swap' solution, which can be made atomic, and could be used...
View ArticleAnswer by David Heffernan for Is struct assignment atomic in C/C++?
Assignments aren't atomic by default , butC and C++ support atomic types in their current standards.C++11 introduced support for atomic types. Likewise C11 introduced atomics.
View ArticleAnswer by sharptooth for Is struct assignment atomic in C/C++?
No, both C and C++ standard don't guarantee assignment operations to be atomic. You need some implementation-specific stuff for that - either something in the compiler or in the operating system.
View ArticleIs struct assignment atomic in C/C++?
I am writing a program which has one process reading and writing to a shared memory and another process only reading it. In the shared memory there is a struct like this:struct A{ int a; int b; double...
View Article