kc5tja,
There are some things missing from 95/98 that NT/2000 provides. I know (from limited experience) that NT/2000 provides CreateWaitableTimer and associated functions. That's what I was thinking would be good for skyler's project, but 95/98 doesn't support them. I suppose the MMTimer stuff he's using is equivalent. And yes, 95/98 does at least provide semaphores, threads, mutexes, etc., so sure, it supports multithreading.
What I'm looking for from either 95/98 or NT/2000 is a wait until an absolute time, not a relative time. For example (in pseudo code):
Code:
EXPIRE TIME = CURRENT TIME
LOOP
CASE TIME EXPIRE MESSAGE:
RUN SIMULATION ( 4000 cycles )
EXPIRE TIME += 1ms
END LOOP
This will always run the simulation on 1ms intervals, unless the PC is too slow. Even then, if the PC got hung up on some printing process or something else, at least the current time marches on and the simulation will eventually catch up. I suppose there are caveats, such as Windows dropping a timer message because it's low priority, but with workarounds such as skyler's, it can be done.
Another approach is to not wait until an absolute expire time, but to "wait until 1ms from now, minus any time already taken." That's a relative-time approach and isn't guaranteed to work because the process can be preempted between calculating the relative time and actually waiting on it.
Skyler's approach using a periodic timer and checking the current time for an "are we already past the 1ms mark?" condition resembles the absolute time method, so it should work.
Scott