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: Devices /
Chapter 6 - Power Manager / Power Manager Reference
Power Manager Dispatch Routines / Sleep Procedures


MySleepProc

A sleep procedure can perform any operations required to prepare your application (or other software) for the sleep state. Your sleep procedure is also called when the computer reawakens.

DESCRIPTION
Your sleep procedure is called at various stages in the Power Manager's sleep and wakeup processes. It is called in response to a sleep request, a sleep demand, a wakeup demand, and a sleep-request revocation. You can determine which of these messages the Power Manager is sending by inspecting the sleep procedure selector code passed in register D0. This code is one of four values:

enum {
   /* sleep procedure selector codes */
   sleepRequest            = 1,     /* sleep request */
   sleepDemand             = 2,     /* sleep demand */
   sleepWakeUp             = 3,     /* wakeup demand */
   sleepRevoke             = 4      /* sleep-request revocation */
};
When called in response to a sleep request, your procedure must either accept or deny the request by either clearing register D0 or leaving it alone. When passed any other selector code, your sleep procedure should take any appropriate actions.

SPECIAL CONSIDERATIONS
A sleep procedure is never executed at interrupt time. As a result, you can, if necessary, call Memory Manager routines or other routines that allocate memory. You can also interact with the user by displaying dialog or alert boxes.

If your sleep procedure displays a dialog or alert box, you should make sure to remove the box after a reasonable amount of time. Failure to do so will prevent the computer from going to sleep and may permanently damage the screen.

ASSEMBLY-LANGUAGE INFORMATION
When your sleep procedure is called, register A0 contains the address of the sleep queue record associated with that procedure and the D0 register contains a sleep procedure selector code.

SEE ALSO
See "Writing a Sleep Procedure," beginning on page 6-20, for instructions on writing a sleep procedure, and see "Installing a Sleep Procedure," beginning on page 6-18, for instructions on installing a sleep procedure.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996