Re: MSDN volatile sample

Because Sleep() is an imported (from system DLL) function, the compiler
cannot make any assumption about whether a global variable will keep its
state across the call. Thus it won't assume that the variable won't be

"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
Hi Alexander,

I throught it is not the 1st time you mentioned Sleep(0) will prevent
compiler to optimize the code. :-)

Do you have any in-depth analysis about how Sleep(0)'s internal mechanism
prevents compiler to optimize read operation? I think some people will be
interested if you could provide some internal perpective analysis beyond

Maybe the straight forward way is to post some assembly code. :-)

regards and have a nice day,