AnsweredAssumed Answered

vrf Delay vs Sleep()

Question asked by VRFuser on Aug 14, 2005
> Maximum horsepower is obtained by
> setting the sleep value to "0" in
> which case the sleep() function is
> not called. So far, the approach
> seems to work OK.

It all sounds quite workable!

Bear in mind that "0" is sometimes useful as a Sleep value:

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

Also:

"In particular, if you specify zero milliseconds, the thread will relinquish
the remainder of its time slice but remain ready."

On the subject of "ready to run", it continues:

"Note that a ready thread is not guaranteed to run immediately.
Consequently, the thread may not run until some time after the specified
interval elapses. For more information, see Scheduling Priorities."

Link for "Scheduling Priorities" (one line):
http://msdn.microsoft.com/library/en-us/dllproc/base/scheduling_priorities.a
sp

PS - This whole question of scheduling is a twisty little passage with no
end. Or maybe it loops back on itself through the fourth dimension - it's
hard to tell. My brain doesn't operate at that level. The thing is, this is
exactly *why* Windows can't exhibit determinism. There are however third
party real time kernels available that will give you determinism back.

PPS - On the time thing in general (just to set the record straight), I once
said that supplying a callback address to SetTimer was more deterministic
than handling WM_TIMER - I was wrong. I *think* your best bet for
deterministic millisecond intervals is multimedia timers, though I may be
wrong about that too. At some point I'll look into it thoroughly, but
admittedly not until I have to   Again, accurately measuring time (even
of fantastically short intervals) is easy. The hard part is figuring out how
to separate code execution time from event interval.
-SHAWN-



---
You are currently subscribed to vrf as: rsb@soco.agilent.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list,  email "vrf@agilent.com". 
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".

Outcomes