11.5 Run-Time Utilities
void *params; - A pointer to parameters for the procedure; this pointer will be passed in to proc.
long period; - the period in milliseconds at which this routine should repeat.
long last_run_msec; - the time at which this routine was last run; used internally by the TIMR Manager; usually initially be set to 0, but can be set to a time in the future, for delayed execution of the proc.
Each time the currently installed TIMR runs its interrupt routine, it will check the queue of interrupt tasks and for each task for which
It is the responsibility of the PSYX which installs a TIMR interrupt task to make sure that the currently installed TIMR has sufficient resolution to be able to run the installed task properly. The temporal resolution of the installed TIMR can be found in
As a general rule, TIMR Interrupt Routines should be small, fast routines, which will not interfere with the normal operation of the program. They also must follow all general rules for Macintosh interrupt routines, including not moving memory, and making sure, if they use global variables, to set and restore A4.
11.5.1.1 theTimer
typedef struct {
void (*connect)(Ptr attribRef,long *resolution,long **millisecs);
void (*disconnect)(void);
void (*start)(void);
void (*stop)(void);
long *millisecs;
long resolution;
TIMRTask *taskListHead;
TIMRTask *taskListTail;
} Timer;
extern Timer theTimer;
The variable
theTimer.milliseconds
is a pointer to the current TIMRs millisecond clock. The current time in milliseconds, as seen by the Trial Manager and all run-time subsystems can be accessed via *(theTimer.milliseconds)
.11.5.1.2 WaitTil()
extern void WaitTil(long time_val);
The function WaitTil() simply waits until the specified absolute time.
11.5.1.3 TIMR Interrupt Tasks
The PsyScope Toolbox provides a utility for attaching functions to the current TIMRs interrupt task. This is done by creating a TIMRTask structure, and adding it to theTimer's interrupt task list using AddTIMRInterruptTask()
. When the task is no-longer needed, it should be removed from the task list using DelTIMRInterruptTask()
.
typedef struct TIMRTask{
struct TIMRTask *next,*prev;
void (*proc)(void *params);
void *params;
long period;
long last_run_msec;
} TIMRTask;
struct TIMRTask *next,*prev; - Maniputated by the TIMR Manager; should initially be set to
NULL
.
void (*proc)(void *params); - The procedure to be run.
*(theTimer.millisecs) - task.last_run_msec >= period
is TRUE, task.proc(task.params)
will be called.theTimer.resolution
. This field contains the frequency of the current TIMR. Thus a TIMR which updates 1000 times per second would have a resolution of 1000.
extern void AddTIMRInterruptTask(TIMRTask *task);
extern void DelTIMRInterruptTask(TIMRTask *task);
These routine add/remove the given task to/from the TIMR Interrupt task queue.
PSYX Programmer's Manual - 24 AUG 95
[Next] [Previous] [Up] [Top] [Contents] [Index]
Generated with CERN WebMaker