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
changed.

"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0D4718E0-5DCB-4762-8D0D-B74BD1442FAF@xxxxxxxxxxxxxxxx
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
the
conclusion.

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


regards and have a nice day,
George



.