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 3 - Time Manager


About the Time Manager

The Time Manager allows applications and other software to schedule routines for execution at a later time. By suitably defining the routine that is to be executed later, you can use the Time Manager to accomplish a wide range of time-related activities. For example, because a routine can reschedule itself for later execution, the Time Manager allows your application to perform periodic or repeated actions. You can use the Time Manager to

The Time Manager provides a hardware-independent method of performing these time-related tasks. In general, you should use the Time Manager instead of timing loops, which can vary in duration because they depend on clock speed and interrupt-handling speed.

To use the Time Manager, you must first issue a request by passing the Time Manager the address of a task record, one of whose fields contains the address of the routine that is to run. Then you need to activate that request by specifying the delay until the routine is to run. The Time Manager uses a Time Manager queue to maintain requests that you issue. The structure of this queue is similar to that of standard operating-system queues. The Time Manager queue can hold any number of outstanding requests, and each application can add any number of entries to the queue. If there are several requests scheduled for execution at exactly the same time, the Time Manager schedules them for execution as close to the specified time as possible, in the order in which they entered the Time Manager queue.

The routine you place in the queue can perform any desired action so long as it does not call the Memory Manager, either directly or indirectly. (You cannot call the Memory Manager because Time Manager tasks are executed at interrupt time.)

The Time Manager introduced in system software version 7.0 is the third version released. The three versions are known as the original Time Manager, the revised Time Manager, and the extended Time Manager. The three versions are all upwardly compatible--that is, each succeeding Time Manager version is a functional superset of the previous one. However, code written for the extended Time Manager may not run properly with either the original or revised version. For this reason, it is sometimes important to know which Time Manager version is available on a specific computer.

You can use the Gestalt function to determine which version of the Time Manager is present. You should pass Gestalt the selector gestaltTimeMgrVersion.

CONST
   gestaltTimeMgrVersion      = 'tmgr';   {Time Manager version}
If Gestalt executes successfully, it returns one of three constants:

CONST
   gestaltStandardTimeMgr     = 1;        {original Time Manager}
   gestaltRevisedTimeMgr      = 2;        {revised Time Manager}
   gestaltExtendedTimeMgr     = 3;        {extended Time Manager}
If Gestalt returns an error, you should assume that the original Time Manager is present. The following sections describe the features of each version of the Time Manager.


Subtopics
The Original Time Manager
The Revised Time Manager
The Extended Time Manager


Previous Book Contents Book Index Next

© Apple Computer, Inc.
17 JUN 1996