<html>
<body>
I have been trying to use sleep() and kernel32.QueryPerformanceCounter
together; I want to delay until a particular tick without trying up the
CPU badly. <br>
However, while time.sleep(.001) relieves the CPU, it has wildly
unpredictable delay, and sleep(.0001) delays almost nothing at all! (I'm
watching the parallel port on a scope).<br>
If I use a while and just count ticks with QueryPerformanceCounter(), it
is very stable and as desired - but it uses 100% CPU.<br><br>
RTAI LINUX has a nanosleep() function that does it all very nicely on our
Debian install, is there a parallel in Win32?<br>
The MS Sleep() function is in integer milliseconds...<br><br>
sample code:<br>
___________________________________________________________________<br>
<br>
TTLHighDur = ticksPerMs/2<br>
currTicksPerRot = fsTicksPerRot<br>
qPC(byref(c0))<br>
tick0 = c0.value # initial count<br>
nextTTL = tick0<br>
## make a TTLOUT <br>
endTick = tick0+pF* 15 #seconds<br>
rotN = 0<br><br>
while(True):<br>
nextTTL = currTicksPerRot+nextTTL<br>
sleep(.0001)# sleep for most of the time needed<br>
while(True): #loop until the exact tick<br>
qPC(byref(c1))<br>
if c1.value>nextTTL:
break<br>
out(0x378, 0xFF) #set all bits high<br>
while(True): #loop until the exact tick<br>
qPC(byref(c1))<br>
if
c1.value>nextTTL+TTLHighDur: break<br>
out(0x378, 0x00) #set all bits low<br>
rotN += 1<br>
<br>
if c1.value>endTick: break<br><br>
<br>
<x-sigsep><p></x-sigsep>
Ray Schumacher<br>
Blue Cove Interactive<br>
8580 Production Avenue, Suite B<br>
San Diego, CA 92121<br>
858.695.8801<br>
<a href="http://Blue-Cove.com" eudora="autourl">http://Blue-Cove.com<br>
<br>
<br>
</a>Disclaimer ;-)<br>
By sending an email to ANY of my addresses you are agreeing that:
<ol>
<li>I am by definition, "the intended recipient"
<li>All information in the email is mine to do with as I see fit and make
such financial profit, political mileage, or good joke as it lends itself
to. In particular, I may quote it on USENET.
<li>I may take the contents as representing the views of your company.
<li>This overrides any disclaimer or statement of confidentiality that
may be included on your message.
</ol></body>
</html>