[comp.sys.mac.programmer] Strange results from using TimeMgr with THINK C

jchoi@ics.uci.edu (John Choi) (02/01/91)

    Is there a bug with the TimeMgr in THINK 4.02 or am I missing something?
I set up a TMTask, inserted the task, and tried to access the tmCount in
a while loop to monitor the count down procedure.  Inside the loop I put
in a TickCount() call to compare the two values.  The TickCount works fine,
returning a long int corresponding to 1/60 sec.  The tm.Count gives me back
a long int which doesn't seem to correspond to much - least of all 1 msec.
The units seem to be something like .4884 msec.  But the real problem I can't
figure out is why the tm.Count variable only gets updated every 4096 units or
about 4 ticks.

    Has anyone tried to use the Time Manager with THINK C?  If you have
any suggestions please help.


    I'd like to thank Landon and Russ of Apple Inc. and Russ for guiding
me to TimeMgr and an article containing the sample code that I'm tring to
run with THINK C on a Mac II.  If only I had a brain ...

Thanks,  John Choi (jchoi@ics.uci.edu)

ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (02/01/91)

According to my interim Inside Mac vol VI dated October 1990, the
tmCount field is "set by RmvTime".

What I interpret this to mean is, the field gets the correct
value as documented only when you call RmvTime. Up until then, its
contents are not officially specified, and could very well be
the time remaining in some strange internal units.

Lawrence D'Oliveiro                       fone: +64-71-562-889
Computer Services Dept                     fax: +64-71-384-066
University of Waikato            electric mail: ldo@waikato.ac.nz
Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00

6500rgls@ucsbuxa.ucsb.edu (Randall S Geels) (02/03/91)

>tm.Count gives me back
>a long int which doesn't seem to correspond to much

Huh? According to my IM IV documentation of the time manager, tmCount
is simply a reserved variable and it doesn't say it's supposed to
correspond to anything. I have been trying to use the time manager and
I find it works pretty much as advertised. I am using the new call
InsXTime in an attempt to not lose any time in processing the interupt.
After repeated calls, however, I find that the time between interrupts
is actually about 10 microseconds less than what I specify in PrimeTime()
when I'm running on a Mac Plus. The error is smaller on the Mac II.
If you need any further info, just let me know.

Randy Geels

6500rgls@ucsbuxa.ucsb.edu (Randall S Geels) (02/03/91)

>tmCount gets set to 10 seconds, but in units of micro seconds,
>not milli seconds.  In addition, it is a negative value

I read somewhere that the new Time Manager can be passed a value in
microseconds by calling PrimeTime() with count a negative number.
Whenever the Time Manager gets a negative number in this fasion it
interprets it as representing the delay in microseconds. Thus it makes
sense that it would use this format internally as well.

Randy Geels