Hi, there,

I am trying to create a very accurate timer (10-15us range), with a resolution of 1us.
I noticed that even if I temporarily change the process's priority class to REAL_TIME_PRIORITY_CLASS and boost the thread priority to maximum there still are longer intervals from time to time.

Is there a way of disabling the interrupts completely? Any other suggestions?
Also, QueryPerformanceCounter does not work under Windows XP Home edition. Does anyone know why?

Thanks,
Posted on 2003-03-29 20:30:38 by VVV
Posted on 2003-03-29 23:07:08 by aweX
Hi, awerX,

These don't seem to work in the microsecond range.
Any other suggestions?

Thanks,
Posted on 2003-03-31 21:17:54 by VVV
LOL! nice1 :grin: :grin:


aweX <-
Posted on 2003-04-01 05:05:37 by aweX
Posted on 2003-04-01 05:12:08 by aweX
If you need microsecond timing accuracy, perhaps you should be writing a driver. Or, if possible, a realtime OS or your own custom kernel.
Posted on 2003-04-01 08:48:34 by f0dder
Aww, I saw somewhere on a way to disable interrupts under win98, but I can't find
Edit:
http://sourcevault.scali.eu.org/cgi-bin/Syntax/Syntax.cgi?ring0.c



I guess this would work:
(I don't know whether you used RDTSC) . Try not to start the code right away, first have a Sleep(0) and SwitchToThread()



include Ring0OnOff.inc ; make it yourself

invoke GetCurrentProcess
invoke SetPriorityClass,eax,REALTIME_PRIORITY_CLASS
invoke GetCurrentThread
invoke SetThreadPriority,eax, THREAD_PRIORITY_TIME_CRITICAL
invoke Sleep,0
invoke SwitchToThread
invoke RING0ON
_again:
RDTSC
push eax


;------------------------\

;.. now do your code
; here

;------------------------/

@@:
RDTSC
pop ecx
sub eax,ecx
cmp eax,7000 ; roughly 15microseconds, calculate for your cpu
ja _again
push ecx
jmp @B

invoke RING0OFF

Posted on 2003-04-03 05:05:34 by Ultrano
ring0 hacks are generally bad, and 9x-only - so be aware you'll need a driver if you go for NT programming (and you sort of ought to on 9x as well).
Posted on 2003-04-03 07:45:15 by f0dder