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 4 - Vertical Retrace Manager


About the Vertical Retrace Manager

The video circuitry in a Macintosh computer, whether built-in or external, refreshes the screen at regular intervals. For built-in monitors, the screen is refreshed approximately 60 times per second; for external monitors, the screen is refreshed at intervals determined by the associated video hardware. To refresh the screen, the monitor's electron beam draws one pixel at a time, starting at the upper-left corner of the screen and moving quickly to the lower-right corner. When the electron beam returns from the lower-right corner of the screen to the upper-left corner, the video circuitry generates a vertical retrace interrupt or vertical blanking (VBL) interrupt.

The Vertical Retrace Manager is the part of the Operating System that schedules and executes tasks--known as VBL tasks--during a vertical retrace interrupt. The Operating System itself uses the Vertical Retrace Manager to perform some important housekeeping operations, such as moving the cursor in response to mouse movements and checking whether the current application's stack has expanded into its heap. Within the limitations described in this chapter, you can use the Vertical Retrace Manager to install your own recurrent tasks. For example, you can use the Vertical Retrace Manager to spin the cursor to indicate that the user must wait while some processing initiated by your application completes.

In general, the Vertical Retrace Manager is useful for small, repetitive tasks that do not allocate or release memory and that you do not want to execute in your main event loop. Whenever possible, it is best to manage periodic tasks within your main event loop. For example, you can call the TextEdit routine TEIdle once each time through the loop, thus causing the insertion point in a block of text to blink. However, if you want some task to execute repetitively at a time when you do not want to reenter your main event loop (perhaps because you don't want your application to be switched out during some lengthy operation), it might be possible to use the Vertical Retrace Manager to execute the task.

The principal limitation on VBL tasks (aside from the limitations on any interrupt-time processing) is that they cannot execute more frequently than once per VBL interrupt. The exact amount of time between successive VBL interrupts depends on the refresh frequency of the screen, which varies. On Macintosh computers that have a built-in screen (such as the Macintosh Plus or Macintosh Classic), the vertical retrace frequency is approximately 60.15 Hz, resulting in a period of approximately 16.63 milliseconds. If you need a task to be executed more often than that, you should use the Time Manager, which has a much finer resolution (up to 250 microseconds for drift-free task execution).

Unlike the Time Manager, the Vertical Retrace Manager is not an absolute timing mechanism. Its operations are always relative to the VBL interrupt, which may be disabled (for instance, during disk access). As a result, you should use the Time Manager in cases where absolute time delays are important. Use the Vertical Retrace Manager, however, in cases where the scheduled actions need simply to be synchronized with other VBL tasks, such as moving the cursor or refreshing the screen.


Subtopics
VBL Tasks Installed by the Operating System
Types of VBL Tasks
The VBL Task Record
Vertical Retrace Queues
VBL Tasks and Application Execution


Previous Book Contents Book Index Next

© Apple Computer, Inc.
17 JUN 1996