Re: MSDN volatile sample

Tech-Archive recommends: Fix windows errors by optimizing your registry



Sorry, it is my mistake. :-)


You are correct.


regards,
George

"Ben Voigt [C++ MVP]" wrote:


"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B2C8AC79-5EC0-49BE-8B42-CC3457CA25F2@xxxxxxxxxxxxxxxx
Hi ajk,


Could you provide a link to your quoted Sleep method description please?

I am reading from,

http://msdn2.microsoft.com/en-us/library/d00bd51t(VS.80).aspx

not the same as you quoted.

I don't believe you. Nothing in that document suggests that Thread.Sleep(0)
would sleep forever unless a signal arrives.

Windows doesn't even have signals (except emulated in the posix
environment), they're a unixy thing.




regards,
George

"ajk" wrote:

On Fri, 28 Dec 2007 03:34:02 -0800, George
<George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

while (Sentinel)
Sleep(0); // volatile spin lock

I think even if the original code will result in deadlock. In the
original
MSDN sample, Sleep(0) will sleep forever until there is a signal sent to
the
sleeping thread. But in the original sample, there is no way to trigger
the
thread from waking up.

The sample works by chance because Sentinel happened to false when we
enters
whle loop.

Any comments? If I am wrong, please feel free to correct me. :-)


no, if you check the documentation of Sleep

<quote>
A value of zero causes the thread to relinquish the remainder of its
time slice to any other thread of equal priority that is ready to run.
If there are no other threads of equal priority ready to run, the
function returns immediately, and the thread continues execution.
</quote>

this means the loop will check 'Sentinel' and once it is set to false
by another thread, the loop will terminate.

/ajk





.



Relevant Pages

  • Re: MSDN volatile sample
    ... Could you provide a link to your quoted Sleep method description please? ... time slice to any other thread of equal priority that is ready to run. ... this means the loop will check 'Sentinel' and once it is set to false ...
    (microsoft.public.vc.language)
  • Re: UK: They banned smoking, now theyre after the sandwiches
    ... rednecks in filthy cells in countries with, shall we say, a more ... heads off with butcher knives and blows up mass transportation systems to make a point and I'm supposed to get upset over some asshole losing some sleep and waterboarding. ... Regards, ...
    (alt.smokers.pipes)
  • Re: MSDN volatile sample
    ... Could you provide a link to your quoted Sleep method description please? ... Windows doesn't even have signals (except emulated in the posix ... this means the loop will check 'Sentinel' and once it is set to false ...
    (microsoft.public.vc.language)
  • Re: ????
    ... flame and scarcely any poetry or any useful critiques at all. ... the final two words of said post being: Sleep is. ... "A deluded fool regards himself as the protector of poetry ..." ...
    (rec.arts.poems)
  • Re: Waiting for MSDE
    ... failedwhen intializing the SqlConnection, ... you can sleep for serveral seconds in the while loop if you feel it ... Regards, ...
    (microsoft.public.sqlserver.setup)