So does operations on char are atomic? So in thread A I read char T and in thread B I write on same char T, are these standard operations atomic?
char a;
#thread A
{
if(a & 0x01)
...
}
#thread B
{
a =0x01;
...
}
# ATOMIC?
Thanks!
So does operations on char are atomic? So in thread A I read char T and in thread B I write on same char T, are these standard operations atomic?
char a;
#thread A
{
if(a & 0x01)
...
}
#thread B
{
a =0x01;
...
}
# ATOMIC?
Thanks!
According to the C++ standard, potentially-concurrent access happens when the same variable is used from multiple threads, and these accesses conflict if at least one access is a write.
Potentially-concurrent accesses that conflict constitutes a data race, which is undefined behavior unless all such accesses are atomic. volatile
will not save you.
Primitive types are not atomic within the meaning used in the C++ standard. You can use the std::atomic
template to make objects which are atomic.