Important: The information in this document is obsolete and should not be used for new development.
Chapter 4 - Vertical Retrace Manager
This chapter describes the Vertical Retrace Manager, the part of the Operating System that schedules and executes recurrent tasks during vertical retrace interrupts. You can use the Vertical Retrace Manager to execute simple, repetitive tasks and avoid having to execute those tasks repeatedly in your application's main event loop.You should read the information in this chapter if you want your application to schedule tasks for execution during a vertical retrace interrupt. For example, you can use the Vertical Retrace Manager to cycle among a series of cursors while some lengthy operation is happening, thus presenting the illusion of a spinning cursor.
In general, you should use the Vertical Retrace Manager only when you need to synchronize actions with the redrawing of the screen or when the tasks don't need to be executed at very precise intervals. As explained later in this chapter, certain conditions can cause the Operating System to turn off vertical blanking interrupts for a period of time. When this happens, the tasks in the vertical retrace task queue are not executed as scheduled. As a result, you should not use the Vertical Retrace Manager to handle tasks that must be executed consistently or with precise timing. For precise, uninterrupted task execution, you should use the Time Manager. See the chapter "Time Manager" in this book for details.
To use this chapter, you need to be familiar with interrupt-time processing and with the general limitations on such processing. The chapter "Introduction to Processes and Tasks" in this book describes these issues in detail. As emphasized in that chapter, you should in general avoid executing tasks at interrupt time. If you must install a VBL task, the code should be as short as possible. In addition, the code and any data it accesses should be locked into physical memory if virtual memory is in operation.
To use this chapter, you might also need to be familiar with techniques for accessing information in your application's A5 world at interrupt time. The chapter "Introduction to Memory Management" in Inside Macintosh: Memory describes the A5 world and the routines you can use to manipulate the A5 register. This chapter provides complete code samples that illustrate how to access your application's A5 world in a VBL task. As a result, you might be able to use the Vertical Retrace Manager to accomplish simple, repetitive tasks without reading that chapter.
This chapter describes how the Vertical Retrace Manager works and then shows how you can use the Vertical Retrace Manager to
- install a simple task to be executed during vertical retrace interrupts
- access information about a task record installed in the vertical retrace queue from within that task
- access your application's global variables in a vertical retrace task
- spin the cursor to indicate that the user must wait while the computer completes some lengthy processing
- install a vertical retrace task in the system heap so that it continues to be executed even when your application is switched out
Chapter Contents
- About the Vertical Retrace Manager
- VBL Tasks Installed by the Operating System
- Types of VBL Tasks
- The VBL Task Record
- Vertical Retrace Queues
- VBL Tasks and Application Execution
- Using the Vertical Retrace Manager
- Installing a VBL Task
- Accessing a Task Record at Interrupt Time
- Accessing Application Global Variables in a VBL Task
- Spinning the Cursor
- Installing a Persistent VBL Task
- Vertical Retrace Manager Reference
- Data Structure
- The VBL Task Record
- Vertical Retrace Manager Routines
- Slot-Based Installation and Removal Routines
- System-Based Installation and Removal Routines
- Utility Routines
- Application-Defined Routine
- VBL Tasks
- Summary of the Vertical Retrace Manager
- Pascal Summary
- Data Type
- Vertical Retrace Manager Routines
- Slot-Based Installation and Removal Routines
- System-Based Installation and Removal Routines
- Utility Routines
- Application-Defined Routine
- C Summary
- Data Types
- Vertical Retrace Manager Routines
- Slot-Based Installation and Removal Routines
- System-Based Installation and Removal Routines
- Utility Routines
- Application-Defined Routine
- Assembly-Language Summary
- Constants
- Data Structures
- VBL Queue Element
- Global Variables
- Result Codes