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,
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,
Use the multimedia timer:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mmtime_3soj.asp
awreX <-
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mmtime_3soj.asp
awreX <-
Hi, awerX,
These don't seem to work in the microsecond range.
Any other suggestions?
Thanks,
These don't seem to work in the microsecond range.
Any other suggestions?
Thanks,
LOL! nice1 :grin: :grin:
aweX <-
aweX <-
If you really want to use Windows for such ultra-sensitive things, look here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Timers.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Timers.asp
If you need microsecond timing accuracy, perhaps you should be writing a driver. Or, if possible, a realtime OS or your own custom kernel.
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()
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
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).