Samuel Thibault, le Wed 23 Dec 2009 10:26:09 +0100, a écrit :
> Da Zheng, le Wed 23 Dec 2009 16:46:34 +0800, a écrit :
> > > If you use volatile, the compiler won't
> > > optimise instructions so it would "work" too ; note however that it's
> > > not SMP safe (it may even not be premption-safe, depending on which
> > > instruction the compiler eventually uses).
> > We don't need both? If there is only volatile, instructions might be 
> > executed out of order and compilers might also reorder instructions.
> 
> Volatile prevents from compiler reorder.

Oops, sorry, of course not. You need the memory clobber for that. Or use
a function call and not assume that ordering will be correct for local
variables.

Samuel


Reply via email to