Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!peregrine!elroy!ames!pasteur!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.sys.mac.programmer Subject: Re: Millisecond timing on Mac II Message-ID: <946@helios.ee.lbl.gov> Date: 7 Sep 88 00:31:35 GMT Article-I.D.: helios.946 References: <1325UD040164@NDSUVM1> <13946@agate.BERKELEY.EDU> <626@sdics.ucsd.EDU> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 53 In article <626@sdics.ucsd.EDU> carrier@sdics.UUCP (Mark Carrier) writes: > >I am trying to get accurate millisecond timing on a Mac II. I >want to record subject reaction times where the responses are >keypresses. Installing a task via the Time Manager seems the >most promising approach, where the task simply increments a >global counter every millisecond. The only problem is that >there does not seem to be a convenient way of making the task >be executed every millisecond. Calling the routine PrimeTime >from within the task itself to reschedule its execution does >not work (the Mac crashes). > >Does anybody know a convenient (or any) way of doing this? Is >it possible? If not, is there some other (perhaps lower-level) >way of achieving millisecond timing? > > > Mark Carrier I am using the Time Manager to do exactly what you describe, namely, reinstalling myself to schedule some future event. Here is a code excerpt: pascal void StepperInt() { SetCurrentA5(); /* set up access to my globals */ CurrentDirection=GridStepper->CurrentDirection; currentTime=INTERRUPT_PERIOD; /* some constant time in milliseconds */ PrimeTime(&TMStepperTask, currentTime); /* code ... */ RestoreCurrentA5(); /* restore previous A5 */ } SetCurrentA5() and RestoreCurrentA5() are routines I wrote in assembly language that use PC relative storage to store and retrieve the current and my values of A5 to solve interrupt global access under multifinder. A third routine, RememberOurA5() is called at application startup to store A5 for later retrieval by the interrupt routine. If there is further interest I will post these routines, but they are easy enough to implement. The reason your calls to PrimeTime() at interrupt time were crashing is probably because you weren't setting up access to your globals properly. I hope this helps. Patrick Beard Lawrence Berkeley Laboratory beard@ux1.lbl.gov The reason you