Important: The information in this document is obsolete and should not be used for new development.
Types of VBL Tasks
There are two general types of VBL tasks. A slot-based VBL task is linked to an external video monitor. Because different monitors can have different refresh rates and hence might execute VBL tasks at different times, the Vertical Retrace Manager maintains a separate task queue for each video device attached to the computer. When a VBL interrupt occurs for a particular device, the Vertical Retrace Manager executes any tasks in the queue for the slot holding that monitor's video card. You can install a slot-based VBL task by calling theSlotVInstall
function.For Macintosh computers that have only a built-in monitor (such as a Macintosh Plus or Macintosh Classic), there is no need to isolate VBL tasks into separate queues. Instead, the Operating System maintains just one task queue and processes the tasks in that queue when it receives a VBL interrupt. A VBL task that is not linked to an external video device is known as a system-based VBL task. You can install a system-based VBL task by calling the
VInstall
function.To maintain compatibility on modular Macintosh computers for software that uses the
VInstall
function, the Operating System generates a special interrupt at a frequency identical to the retrace rate on compact Macintosh computers. This special interrupt is generated approximately 60.15 times a second and mimics the vertical retrace interrupt on compact models. This ensures that application tasks installed using theVInstall
function, as well as periodic system tasks such as updating the tick count and checking whether the stack has expanded into the heap, are performed as usual.To ensure the synchronization of your VBL task with the retracing of the screen, you should check whether the
SlotVInstall
function is available in the current operating environment. If it is, you should use the slot-based routines to install and remove your VBL task. If not, you should use the system-based routines.However, even if you synchronize your VBL task to the retracing of the screen correctly, tasks may not always execute as scheduled. Some types of system activity, such as disk access, may cause VBL interrupts to be disabled temporarily. (This is why cursor movement sometimes becomes jerky during disk operations.) Also, if a VBL task takes longer to perform than the time it takes to retrace the screen, other interrupt tasks may miss one or more vertical retrace interrupts.
Like all interrupt tasks, VBL tasks cannot do everything that ordinary routines can. The following list summarizes the operations that VBL tasks should not perform. A VBL task that violates one of these rules may cause a system crash:
- A VBL task must not allocate, move, or purge memory, or call any Toolbox routines that might do so.
- A VBL task must preserve all registers other than A0-A3 and D0-D3.
- A VBL task cannot call a routine from another code segment unless it sets up the application's A5 world properly. In addition, that segment must already be loaded in memory.
- A VBL task cannot access your application global variables unless it sets up the application's A5 world properly. This technique is explained in "Accessing Application Global Variables in a VBL Task," beginning on page 4-13.
- A VBL task's code and any data accessed during the execution of the task must be locked into physical memory if virtual memory is in operation.