ric@mcrware.UUCP (Ric Yeates) (07/19/90)
Netlanders:
I have been doing some work lately with MIDI and have run across the
following strange behavior (not MIDI related).
Here is the code (please excuse the formatting [brevity]):
#include <osbind.h>
#include <stdio.h>
unsigned long tick;
gt() { tick = *(long *)0x4ba; } /* get tick counter */
st() { *(long *)0x4ba = tick; } /* set tick counter */
unsigned long get_tick() /* get the tick counter from system */
{
Supexec(gt); return tick;
}
set_tick(ticks) /* set the system tick counter */
unsigned long ticks;
{
tick = ticks; Supexec(st);
}
wait(sec) /* wait for <sec> seconds */
float sec;
{
long stop = (int)(sec * 200) + get_tick();
while (get_tick() < stop);
}
main()
{
register int i;
for (i = 0; i < 20; i++) {
wait(0.5); /* wait for half a second */
set_tick((long)i); /* set the tick counter to some value */
}
}
When I run this program, it seems to complete without a problem.
The next time I access the hard disk (from Laser C) my mouse pointer
turns into a "bee" and never comes back. The problem seems to also be
related to both calling wait and set_tick together (either alone will
not cause this).
What I'm asking is: Can someone else try this under Laser C? Can
someone try this under some other C Compiler? Is there really something
wrong (other than the fact that it's a polling loop [I'm aware of
evnt_timer])?
Thanks for the consideration.
Ric Yeates.