[comp.os.os2.programmer] Short interval timer

seg@ingres.com (scott e garfinkle) (06/26/91)

In article <1991Jun24.040943.19084@kcbbs.gen.nz> Chris_Sullivan@kcbbs.gen.nz (Chris Sullivan) writes:
>I need to time an interval of several milliseconds.  I can't use the
>Dos timer calls (DosSleep etc) because their granularity is one
>tick of the system closk (30ms).  Is there any way to accurately
>time intervals much less than the system clock period?

I think that there is *no* way to do this under OS/2 1.x.  Under 2.0, you
will get somewhat better resolution if you have a thread designated as
PRTYC_TIMECRITICAL and you set a timer.  In this case the thread, now in
the "fast dispatch" category, will have much better resolution when it 
approaches the end of the timer period.  ("hat resolution," you ask?
I think that this is somewhat in flux, but I think you can probably count
on at least 2-3x better than normal.

In general, by the way, the easiest way to get elapsed time is to use the
DosGetInfoSeg to get a pointer to the ginfoseg.  The "msecs" parameter there
is "current system time in milliseconds."  just save a copy and subtract from
the current value to get elapsed time with millisecond precision (and
whatever accuracy you get, as above).

This is all the stuff I know about.  Someone familiar with the OS/2
kernel may want to improve on this.
	-scott e. garfinkle

Standard Disclaimer.