Important: The information in this document is obsolete and should not be used for new development.
Installing a Deferred Task
The Deferred Task Manager provides a single routine,DTInstall
, that you can use to install elements into the deferred task queue. The deferred task queue is a standard operating-system queue whose elements are defined by theDeferredTask
data type.
TYPE DeferredTask = RECORD qLink: QElemPtr; {next queue entry} qType: Integer; {queue type} dtFlags: Integer; {reserved} dtAddr: ProcPtr; {pointer to task} dtParm: LongInt; {optional parameter passed in A1} dtReserved: LongInt; {reserved; should be 0} END;Your application or driver needs to fill in only theqType
,dtAddr
, anddtReserved
fields. ThedtAddr
field specifies the address of the routine whose execution you want to defer. You can also specify a value for thedtParm
field, which contains an optional parameter that is loaded into register A1 just before the routine specified by thedtAddr
field is executed. ThedtFlags
anddtReserved
fields of the deferred task record are reserved. You should set thedtReserved
field to 0.Listing 6-2 defines a routine,
InstallDeferredTask
, for installing a task element in the deferred task queue. This element corresponds to the routineMyDeferredTask
, which does the real work of your interrupt task. TheInstallDeferredTask
routine sets up a deferred task record and then installs it in the deferred task queue by calling theDTInstall
function. Note that you should callDTInstall
only at interrupt time.Listing 6-2 Installing a task into the deferred task queue
PROCEDURE InstallDeferredTask (theTask: DeferredTask); VAR myErr: OSErr; BEGIN WITH theTask DO BEGIN qType := ORD(dtQType); {set the queue type} dtAddr := @MyDeferredTask; {set address of deferred task} dtParm := 0; {no parameter needed here} dtReserved := 0; {clear reserved field} END; myErr := DTInstall(@theTask); END;