Context Switching
Applications running in the background receive processing time when the
front application makes an event call (that is, calls WaitNextEvent, front application. An application running in the background should relinquish
the CPU regularly to ensure a timely return to the foreground application
when necessary.
In System 7.0+ (or under MultiFinder in earlier versions), the available processing time is distributed among multiple applications through a
procedure known as context switching (or just switching). When a context
that is different from the one that had been receiving processing time. Two
types of context switching may occur: major and minor. All switching occurs
at a well- defined time, namely, when an application calls WaitNextEvent. A major switch is a complete context switch: an application's windows are moved from the background to the foreground, or vice versa. In a major switch,
two applications are involved, the one being switched to the foreground and the
one being switched to the background. The A5 worlds of both applications are
switched, as well as the relevant low-memory environment. If those
applications receive suspend and resume events, they are so notified at the
time that a major switch occurs.
Major switching does not occur when a modal dialog box is the frontmost
window, although minor switching (discussed next) can still occur. To
determine whether major switching can occur, the Operating System checks
(among other things) to see if the window definition procedure of the frontmost
window is dBoxProc because the type dBoxProc is specifically reserved for
modal dialog boxes. (Major switching can still occur when a movable modal
dialog box is the frontmost window.)
A minor switch occurs when an application is switched out to give time to background processes. A minor switch always involves two applications, a
background application and the application yielding time to it (which may be
some other background application). In a minor switch, the A5 worlds of those
two applications are switched, as are the low-memory environments.
However, the layers of windows are not switched, and neither application
receives either suspend or resume events.
Note: Your application can also get switched out if it calls a PPC Toolbox routine that makes an event call. For example, your application may get