M
Michael Furman
Jerry Coffin said:[ ... ]
In the specific case of a boolean, most of these problems are likely to
be covered up by the fact that in a boolean, only one bit is really
significant. The rest of the storage unit in which the boolean is
stored may be modified non-atomically, but it's difficult for the
modification of one bit to be non-atomic.
OTOH, I don't think there's any requirement or guarantee that a boolean
be stored as a single bit -- an implementation might (for example) store
0 and 0xffff for false and true respectively. In this case, if it reads
what's supposed to be a boolean, but happens to contain (for example)
0x00ff, it might decide something is defective, and halt the program
entirely. I'm not sure such an implementation exists, but I'm far from
certain it can't either.
End even more - even in case of one bit, I don't think that there's any
requirement or guarantee, that if you change false->true, every reader
will see sequence "false.false.....true.true..." rather then
"false.false.true.false.true.true.....".
For example I worked with flash memory, that gave some strange values
for some time period after write (actually one bit was flashing and other
bits were undefined).
Regards,
Michael