Hi everyone,
i am sort of new in tihis stuff,acctually i just starting.I need a timer realized with assembler so it can run in win console apps.i hope the asm is my last chance since MFC and other win related stuff do not satisfy my needs.Here is the problem:i need to develop a C++ class which will take some action every 20ms.Accuracy is the must.It must be possible to "kill" and "start" timer from out of program(i resolve this with handles).Threads and win timers can not give me what i need,can asm do?Is there any way to "catch" processor clock at given time period with asm?Any help,tip,idea,... will be of great help.

Posted on 2004-06-17 10:46:35 by nikoladsp
You could code a driver if you want _the_ best precision - but I advice against this ;)

If you raise your process+thread priority, and call some API which name I can't remember :/, you can get more accuracy for Sleep(), which would let you control the timer through threading.

Timing is a pretty tough problem on multitasking&protected operating systems, and it's been discussed here and other places a lot of times. Don't use RDTSC, as it can drift with power-saving schemes. Look into the multimedia timers, I believe they will use the APIC timer if available.
Posted on 2004-06-17 11:00:16 by f0dder
i want use threads anyway,Sleep() is a killer for precision which must be about 100microsec.I saw some articles about using some interrupts and "pump" in it some fake interrupts to have more resolution.I tried MMtimers,but problem is that my class won't be used under windows-it will be used in some mobile-phone project in some custom famework,...
I know that windows is not RTOS so i just wanna know is this what i need is possible to do anyhow at all...

thanks & cheers.
Posted on 2004-06-17 13:12:16 by nikoladsp
Is the Timer API function not good enough? I heard that its resolution is around 10ms on WindowsNT/2K/XP systems. It's really easy to implement in asm too.
Posted on 2004-06-17 13:49:26 by DeX
Don't know if these help, but they seem to sugest the 10ms resolution DeX mentioned:


Edit: sorry, didn't read the bit about you already having tried these :)
Posted on 2004-06-17 14:12:22 by Jibz
Thanks guys for helping.
you see i need good precision cause i need to measure time intervals of message packets arrival( QuerryPerformance... do a good job here) but problem arises when i need to send packages every 20milisec,get system time at get jitter.This i can't do with any win timer cause there are those mean win threading stuff:nobody guarantees me that my thread wont be suspended for say 3milisec which will ruined my measurement.
Posted on 2004-06-18 04:25:57 by nikoladsp
It does seem like windows isn't the best platform for what you want :) - I assume setting process+thread priority to realtime isn't really an option for you either.

You're prototyping stuff on windows, then going to move it to the cellphone stuff later on?
Posted on 2004-06-21 03:55:01 by f0dder
You are right,
i develop some Symbian stuff and later we put it onto phones.For some experiment purposes we need to test some jitter and package loss.These testings needs to be implemented on Windows and on Symbian.I already wrote class to measure time elapsed between packages arrival an getting system time in NPS time format but problem arises in impementing clock to tick every 20milisec.Threads does not help me cause they can (and most probably will) cause a mistakes in measurement,so practically i do have solution already but i am serching alternative(read better solutions).
thanks for the help.
Posted on 2004-06-21 05:20:05 by nikoladsp