3 ms·
The hardware will reorder references regardless of how many of them are marked volatile - CPU doesn't know about volatile directives. The other related problem
by DenisM 17y ago
The hardware will reorder references regardless of how many of them are marked volatile - CPU doesn't know about volatile directives. The other related problem is caching - reading the same address from different CPUs will occasionally yield different results and may produce inconsistent results. Like so:
a=b=c=1;a=2;b=2;c=2;
Reading from a different CPU may produce any combination of values 1 and 2, including the seemingly impossible 2,1,2.
Just use a library.