Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Processes
Chapter 6 - Deferred Task Manager / Using the Deferred Task Manager

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 the DeferredTask data type.

TYPE DeferredTask =
   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}
Your application or driver needs to fill in only the qType, dtAddr, and dtReserved fields. The dtAddr field specifies the address of the routine whose execution you want to defer. You can also specify a value for the dtParm field, which contains an optional parameter that is loaded into register A1 just before the routine specified by the dtAddr field is executed. The dtFlags and dtReserved fields of the deferred task record are reserved. You should set the dtReserved 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 routine MyDeferredTask, which does the real work of your interrupt task. The InstallDeferredTask routine sets up a deferred task record and then installs it in the deferred task queue by calling the DTInstall function. Note that you should call DTInstall only at interrupt time.

Listing 6-2 Installing a task into the deferred task queue

PROCEDURE InstallDeferredTask (theTask: DeferredTask);
   myErr:   OSErr;
   WITH theTask DO
      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}
   myErr := DTInstall(@theTask);

Previous Book Contents Book Index Next

© Apple Computer, Inc.
17 JUN 1996