Is Updating double operation atomic
Posted
by Yan Cheng CHEOK
on Stack Overflow
See other posts from Stack Overflow
or by Yan Cheng CHEOK
Published on 2009-08-18T09:14:20Z
Indexed on
2010/03/18
9:51 UTC
Read the original article
Hit count: 492
c++
|visual-c++
In Java, updating double and long variable may not be atomic, as double/long are being treated as two separate 32 bits variables.
http://java.sun.com/docs/books/jls/second_edition/html/memory.doc.html#28733
In C++, if I am using 32 bit Intel Processor + Microsoft Visual C++ compiler, is updating double (8 byte) operation atomic?
I cannot find much specification mention on this behavior.
When I say "atomic variable", here is what I mean :
Thread A trying to write 1 to variable x. Thread B trying to write 2 to variable x.
We shall get value 1 or 2 out from variable x, but not an undefined value.
© Stack Overflow or respective owner