#ifndef TIMEMANAGER_H #define TIMEMANAGER_H // Routines to make installing Time Manager interupts easy in applications. // Sets up A5 so you can get to your globals.... // The required asm glue code is where you dont have to look at it. // James Davis - jedavis@cs.stanford.edu - Copyright 1996 #include "timer.h" //typedef TMTask *TMTaskPtr; // Install a task with the Time Manager. Should specify a routine declared as // pascal void myTimeRoutine(void); // Unlike using the TimeManager directly we carefully save off the application // A5 and install a stub routine. This routine resets the application A5 so // that we can access globals in our time manager interupt routine. The stub // then activates our routine. Roughly analogous to the InsTime() call. // returns a pointer to the task record, keep this for scheduling and removal. // You can specify NULL, if you dont want a routine to run, but want to // take timing measurements. // Make sure you remove all tasks before your application exits. TMTaskPtr TM_InstallTask(TimerUPP taskProc); // Remove a previously installed task. Pass the pointer that was returned from // TM_InstallTask(). We clean up a little memory, but otherwise similar // to RmvTime() // Returns the remaining time until the task would have run. May return // negative microseconds even if time was originally in milliseconds. // You can subtract this from the specified interval to find elapsed time. // NIM Processes 3-12 for more info. long TM_RemoveTask(TMTaskPtr tmtask); // Schedule a previously installed task, specify the task pointer, and the // length of time to wait until the task will run. Positive values indicate // milliseconds, and negative values indicate microseconds // The task will run once when the timer expires void TM_ScheduleTask(TMTaskPtr task, long count); // Use to reschedule a task from within the task interupt routine. For instance // to run a periodic task every 50 milliseconds. Initially schedule the task // for 50 milliseconds, and TM_RescheduleTask(50) as the last line of the // interupt routine. // This only works assuming your time manager interupt isnt in turn interupted // by another time manager interupt. I dont think this ever happens, so all // should be groovy, but not positive. // void TM_RescheduleTask(long count); #define TM_RescheduleTask(x) TM_ScheduleTask(TM_RecentTask,(x)); extern TMTaskPtr TM_RecentTask; // Private data structure #endif