#ifndef DEFERREDTASK_H #define DEFERREDTASK_H // James Davis - jedavis@cs.stanford.edu - Copyright 1996 // The deferred task manager allows you to defer execution of some tasks // until after all interupts have been serviced. In some cases this is // advantagous, since your code wont as adversly effect system performance, and // you'll execute at interupt level 0, so wont mask as many other interupts // that you might need to be happening. // Your code still happens at interupt time, so dont be messing with memory and //other evil things. // Deferred task only run once, and then get deinstalled, you need to // reshecule it if you need it to run several times. #include "OSUtils.h" // The maximum deferred tasks you think you might have active at one time. // We need to preallocate some memory at non-interupt time, so we grab what // we think we'll need at application run time. They get reused, so unless // you have lots of simultaneous task you should be fine #define DT_MAX_DEFERRED_TASKS 20 // Install a task in the deferred task queue. Actually calls a stub routine and // saves the current A5 in the task param, so the stub can reset the application // A5 before calling your routine. Since this requires a little piece of asm // glue its handy to have it abstracted. We just reset the A5 that was active at // the time of this call, so make sure the application A5 is set on entry if you // want to use app globals in your deferred routine. // You should only be installing deferred tasks from within interupts. If you want // a periodic repeating task, then use the time manager, and call this from // your time manager task. // Your deferred routine should be declared as: // pascal void myDeferredTask(void) void DT_InstallDeferredTask(DeferredTaskUPP deferredTask); #endif