Good advice for all C programmers out there.
embedded.com
embedded.com
The problem with volatile is that if mark everything volatile you program is just going to run a lot slower. If you don't make all of them volatile it is still possible the hardware could reorder references even if the compiler doesn't.
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.