← Inside Macintosh: Processes

Inside Macintosh: Processes

From the originals

13 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

Image 1

INSIDE MACINTOSH Processes Addison-Wesley Publishing Company Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam Bonn Sydney Singapore Tokyo Madrid San Juan Paris Seoul Milan Mexico City Taipei

A plain white title page with a small black Apple logo at top, the spaced capital title INSIDE MACINTOSH above a horizontal rule and the word Processes, and a small publisher emblem with the Addison-Wesley imprint and city list at the lower part.

Reading notes: Reading order of the city list is left to right by line as printed; the small publisher emblem carries no text.

Languages
English
PDF page 1

Addison-Wesley Publishing Company Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam Bonn Sydney Singapore Tokyo Madrid San Juan Paris Seoul Milan Mexico City Taipei Processes I N S I D E M A C I N T O S H

Reading notes: Transcript is intentionally empty per instruction because exact text is preserved separately; fields were filled from the supplied extracted copy rather than from direct visual reading of the image. The headline was taken as the spaced-capital title INSIDE MACINTOSH, and the subtitle Processes is not confirmed as a headline. The city and office names are listed in three to four lines with multiple spaces between them; the reading order follows the supplied copy and could not be verified visually. No advertised products, prices, or printed dates were present in the supplied copy.

Languages
English
PDF page 2

Apple Computer, Inc. © 1992, Apple Computer, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, mechanical, electronic, photocopying, recording, or otherwise, without prior written permission of Apple Computer, Inc. Printed in the United States of America. No licenses, express or implied, are granted with respect to any of the technology described in this book. Apple retains all intellectual property rights associated with the technology described in this book. This book is intended to assist application developers to develop applications only for Apple Macintosh computers. Apple Computer, Inc. 20525 Mariani Avenue Cupertino, CA 95014 408-996-1010 Apple, the Apple logo, APDA, A/UX, LaserWriter, LocalTalk, Macintosh, MPW, and MultiFinder are trademarks of Apple Computer, Inc., registered in the United States and other countries. Classic is a registered trademark licensed to Apple Computer, Inc. Apple DeskTop Bus, Finder, Macintosh Quadra, PowerBook, and QuickDraw are trademarks of Apple Computer, Inc. Adobe Illustrator and PostScript are trademarks of Adobe Systems Incorporated, which may be registered in certain jurisdictions. AGFA is a trademark of Agfa-Gevaert. FrameMaker is a registered trademark of Frame Technology Corporation. Helvetica and Palatino are registered trademarks of Linotype Company. ITC Zapf Dingbats is a registered trademark of International Typeface Corporation. NuBus is a trademark of Texas Instruments. Simultaneously published in the United States and Canada. LIMITED WARRANTY ON MEDIA AND REPLACEMENT ALL IMPLIED WARRANTIES ON THIS MANUAL, INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE LIMITED IN DURATION TO NINETY (90) DAYS FROM THE DATE OF THE ORIGINAL RETAIL PURCHASE OF THIS PRODUCT. Even though Apple has reviewed this manual, APPLE MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS MANUAL, ITS QUALITY, ACCURACY, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. AS A RESULT, THIS MANUAL IS SOLD “AS IS,” AND YOU, THE PURCHASER, ARE ASSUMING THE ENTIRE RISK AS TO ITS QUALITY AND ACCURACY. IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES RESULTING FROM ANY DEFECT OR INACCURACY IN THIS MANUAL, even if advised of the possibility of such damages. THE WARRANTY AND REMEDIES SET FORTH ABOVE ARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer, agent, or employee is authorized to make any modification, extension, or addition to this warranty. Some states do not allow the exclusion or limitation of implied warranties or liability for incidental or consequential damages, so the above limitation or exclusion may not apply to you. This warranty gives you specific legal rights, and you may also have other rights which vary from state to state. ISBN 0-201-63241-1 1 2 3 4 5 6 7 8 9-MU-9695949392 First Printing, August 1992

Reading notes: No image was supplied, so layout and visual details could not be verified from the scan. The headline is null because the supplied copy has no advertising headline; 'LIMITED WARRANTY ON MEDIA AND REPLACEMENT' is a section heading, not a headline. This is a manual or legal page, not an advertisement, so no advertised products or prices are listed. The printed number line '1 2 3 4 5 6 7 8 9-MU-9695949392' is a printing code and was not treated as a date. Trademark names such as Macintosh and LaserWriter appear in the copy but are not advertised products and were not listed. Transcript is empty per instructions because the exact extracted text is preserved separately.

Printed dates
© 1992 · August 1992 · 1992
Languages
English
PDF page 3

iii Contents Figures and Listings ix Preface About This Book xi Format of a Typical Chapter xii Conventions Used in This Book xiii Special Fonts xiii Types of Notes xiii Assembly-Language Information xiii Development Environment xiv Chapter 1 Introduction to Processes and Tasks 1-1 The Cooperative Multitasking Environment 1-3 About Processes 1-5 Process Creation 1-6 Process Scheduling 1-7 About Tasks 1-9 Task Creation 1-10 Task Scheduling 1-11 Task Guidelines 1-13 Chapter 2 Process Manager 2-1 About the Process Manager 2-3 Using the Process Manager 2-4 Getting Information About Other Processes 2-5 Launching Other Applications 2-7 Launching Desk Accessories 2-11 Terminating an Application 2-11 Process Manager Reference 2-13 Constants 2-13 Gestalt Selector and Response Bits 2-14 Process-Identification Constants 2-14 Launch Options 2-15 Data Structures 2-16 Process Serial Number 2-16 Process Information Record 2-16 Launch Parameter Block 2-19 Application Parameters Record 2-20

Languages
English
PDF page 4

iv Routines 2-21 Getting Process Information 2-21 Launching Applications and Desk Accessories 2-28 Terminating Processes 2-31 Summary of the Process Manager 2-32 Pascal Summary 2-32 Constants 2-32 Data Types 2-33 Routines 2-34 C Summary 2-35 Constants 2-35 Data Types 2-36 Routines 2-38 Assembly-Language Summary 2-39 Data Structures 2-39 Trap Macros 2-40 Result Codes 2-40 Chapter 3 Time Manager 3-1 About the Time Manager 3-3 The Original Time Manager 3-4 The Revised Time Manager 3-5 The Extended Time Manager 3-6 Using the Time Manager 3-9 Installing and Activating Tasks 3-10 Using Application Global Variables in Tasks 3-11 Performing Periodic Tasks 3-13 Computing Elapsed Time 3-14 Time Manager Reference 3-17 Data Structures 3-17 Time Manager Routines 3-18 Application-Defined Routine 3-22 Time Manager Tasks 3-22 Summary of the Time Manager 3-23 Pascal Summary 3-23 Constants 3-23 Data Types 3-23 Time Manager Routines 3-24 Application-Defined Routine 3-24 C Summary 3-24 Constants 3-24 Data Types 3-24 Time Manager Routines 3-25 Application-Defined Routine 3-25 Assembly-Language Summary 3-25

Reading notes: Source is a table of contents, not advertising copy; no headline, product, price, or date is explicitly present.

Languages
English
PDF page 5

Chapter 4 Vertical Retrace Manager

v Data Structures 3-25 Result Codes 3-26 Chapter 4 Vertical Retrace Manager 4-1 About the Vertical Retrace Manager 4-4 VBL Tasks Installed by the Operating System 4-5 Types of VBL Tasks 4-5 The VBL Task Record 4-6 Vertical Retrace Queues 4-8 VBL Tasks and Application Execution 4-8 Using the Vertical Retrace Manager 4-10 Installing a VBL Task 4-10 Accessing a Task Record at Interrupt Time 4-12 Accessing Application Global Variables in a VBL Task 4-13 Spinning the Cursor 4-16 Installing a Persistent VBL Task 4-20 Vertical Retrace Manager Reference 4-21 Data Structure 4-21 The VBL Task Record 4-21 Vertical Retrace Manager Routines 4-22 Slot-Based Installation and Removal Routines 4-22 System-Based Installation and Removal Routines 4-24 Utility Routines 4-26 Application-Defined Routine 4-28 VBL Tasks 4-28 Summary of the Vertical Retrace Manager 4-31 Pascal Summary 4-31 Data Type 4-31 Vertical Retrace Manager Routines 4-31 Application-Defined Routine 4-31 C Summary 4-32 Data Types 4-32 Vertical Retrace Manager Routines 4-32 Application-Defined Routine 4-32 Assembly-Language Summary 4-33 Constants 4-33 Data Structures 4-33 Global Variables 4-33 Result Codes 4-33

Languages
English
PDF page 6

vi Chapter 5 Notification Manager 5-1 About the Notification Manager 5-3 Using the Notification Manager 5-6 Creating a Notification Request 5-6 Defining a Response Procedure 5-9 Installing a Notification Request 5-9 Removing a Notification Request 5-10 Notification Manager Reference 5-10 Notification Manager Routines 5-10 Application-Defined Routine 5-12 Notification Response Procedures 5-12 Summary of the Notification Manager 5-14 Pascal Summary 5-14 Constant 5-14 Data Types 5-14 Notification Manager Routines 5-14 Application-Defined Routine 5-14 C Summary 5-15 Constant 5-15 Data Types 5-15 Notification Manager Routines 5-15 Application-Defined Routine 5-15 Result Codes 5-15 Chapter 6 Deferred Task Manager 6-1 About the Deferred Task Manager 6-3 Using the Deferred Task Manager 6-6 Checking for the Deferred Task Manager 6-6 Installing a Deferred Task 6-7 Defining a Deferred Task 6-8 Deferring a Slot-Based VBL Task 6-9 Deferred Task Manager Reference 6-11 Data Structure 6-11 Deferred Task Manager Routine 6-12 Application-Defined Routine 6-13 Deferred Tasks 6-13 Summary of the Deferred Task Manager 6-14 Pascal Summary 6-14 Data Type 6-14 Deferred Task Manager Routine 6-14 Application-Defined Routine 6-14 C Summary 6-14 Data Type 6-14 Deferred Task Manager Routine 6-15

Reading notes: Table of contents format; primary heading taken from first chapter line as printed

Languages
English
PDF page 7

vii Application-Defined Routine 6-15 Assembly-Language Summary 6-15 Global Variables 6-15 Result Codes 6-15 Chapter 7 Segment Manager 7-1 About the Segment Manager 7-3 Code Segmentation 7-4 The Jump Table 7-5 Using the Segment Manager 7-8 Unloading Code Segments 7-8 Loading Code Segments 7-9 Segment Manager Reference 7-10 Routine 7-10 Summary of the Segment Manager 7-11 Pascal Summary 7-11 Routine 7-11 C Summary 7-11 Routine 7-11 Assembly-Language Summary 7-11 Global Variables 7-11 Advanced Routine 7-11 Chapter 8 Shutdown Manager 8-1 About the Shutdown Manager 8-3 The Shutdown Process 8-4 Closing Open Applications 8-5 Checking for Custom Shutdown Procedures 8-5 Checking for Open Device Drivers 8-5 Saving the Desk Scrap 8-6 Unmounting Volumes 8-6 Turning Off the Computer 8-6 Using the Shutdown Manager 8-7 Sending a Shutdown or Restart Event 8-7 Installing a Custom Shutdown Procedure 8-9 Shutdown Manager Reference 8-11 Shutdown Manager Routines 8-11 Shutting Down or Restarting a Macintosh Computer 8-12 Installing or Removing a Shutdown Procedure 8-13 Application-Defined Routine 8-16 Shutdown Procedures 8-16 Summary of the Shutdown Manager 8-18

Languages
English
PDF page 8

viii Pascal Summary 8-18 Constants 8-18 Shutdown Manager Routines 8-18 Application-Defined Routine 8-18 C Summary 8-19 Constants 8-19 Data Types 8-19 Shutdown Manager Routines 8-19 Application-Defined Routine 8-19 Assembly-Language Summary 8-20 Constants 8-20 Trap Macros Requiring Routine Selectors 8-20 Glossary GL-1 Index IN-1

Reading notes: Source appears to be a table of contents fragment; headline not identifiable

Languages
English
PDF page 9

ix Figures and Listings Chapter 1 Introduction to Processes and Tasks 1-1 Figure 1-1 The desktop with several applications open 1-4 Chapter 2 Process Manager 2-1 Listing 2-1 Searching for a specific process 2-6 Listing 2-2 Launching an application 2-10 Listing 2-3 Terminating an application 2-12 Chapter 3 Time Manager 3-1 Figure 3-1 Original and revised Time Managers (drifting, unpredictable frequency) 3-7 Figure 3-2 The extended Time Manager (drift-free, fixed frequency) 3-7 Listing 3-1 Installing and activating a Time Manager task 3-10 Listing 3-2 Passing the address of the application’s A5 world to a Time Manager task 3-12 Listing 3-3 Defining a Time Manager task that can manipulate global variables 3-13 Listing 3-4 Defining a periodic Time Manager task 3-14 Listing 3-5 Calculating the time required to install and activate a Time Manager task 3-15 Listing 3-6 Calculating the time consumed by a 1-tick delay 3-16 Chapter 4 Vertical Retrace Manager 4-1 Listing 4-1 Checking whether you can use slot-based VBL routines 4-11 Listing 4-2 Determining the slot number of the main graphics device 4-11 Listing 4-3 Initializing and installing a task record 4-12 Listing 4-4 Finding the address of the task record from within a VBL task 4-12 Listing 4-5 Resetting a VBL task so that it executes again 4-13 Listing 4-6 Storing the value of the A5 register directly after the task record in memory 4-14 Listing 4-7 Saving the value of the A5 register when installing a VBL task 4-14 Listing 4-8 Setting up the A5 register and modifying a global variable in a VBL task 4-15 Listing 4-9 Modifying application global variables in a VBL task 4-15 Listing 4-10 Setting up and restoring the A5 register in a VBL task 4-16 Listing 4-11 Defining a cursor information record 4-17 Listing 4-12 Changing the cursor within a VBL task 4-17

Languages
English
PDF page 10

x Listing 4-13 Installing the cursor-spinning task into a vertical retrace queue 4-18 Listing 4-14 Removing the cursor-spinning task from its vertical retrace queue 4-19 Listing 4-15 Installing a persistent VBL task 4-20 Chapter 5 Notification Manager 5-1 Figure 5-1 A notification in the Application menu 5-4 Figure 5-2 A notification alert box 5-5 Listing 5-1 Setting up a notification record 5-8 Chapter 6 Deferred Task Manager 6-1 Listing 6-1 Checking for the availability of the Deferred Task Manager 6-6 Listing 6-2 Installing a task into the deferred task queue 6-7 Listing 6-3 Finding the value of the A1 register 6-8 Listing 6-4 Defining a deferred task 6-8 Listing 6-5 Deferring cursor updating to noninterrupt time 6-9 Chapter 7 Segment Manager 7-1 Figure 7-1 The location of the jump table 7-5 Figure 7-2 The structure of segment 0 7-6 Figure 7-3 Format of an MPW jump table entry when the segment is unloaded 7-7 Figure 7-4 Format of an MPW jump table entry when the segment is loaded 7-8 Chapter 8 Shutdown Manager 8-1 Figure 8-1 A shutdown alert box 8-6 Listing 8-1 Sending a Shutdown event 8-8 Listing 8-2 A sample custom shutdown procedure 8-10

Languages
English
PDF page 11

P R E F A C E

xi P R E F A C E About This Book This book describes the parts of the Macintosh Operating System that allow you to manage processes and tasks. It includes introductory material about managing processes on Macintosh computers as well as a complete technical reference to the Process Manager, the Time Manager, the Vertical Retrace Manager, and other process-related services provided by the system software. If you are new to programming on the Macintosh Operating System, you should begin with the chapter “Introduction to Processes and Tasks.” This chapter provides a general introduction to process and task management on Macintosh computers. It describes how the Operating System controls access to the CPU and other system resources to create a cooperative multitasking environment in which your application and any other open applications run. This environment is managed primarily by the Process Manager, which is responsible for launching processes, scheduling their use of the available system resources, and handling their termination. This chapter also describes how your application can install tasks that are executed asynchronously from your application, usually in response to interrupts. You can n execute a task after a certain amount of time has elapsed n execute a task repetitively n notify the user while your application is in the background n execute a task between screen refreshes n execute a routine as part of the shutdown or restart process Once you are familiar with basic process and task management on Macintosh computers, you might need to look at the chapter “Process Manager.” It describes how you can get information about open processes and, if necessary, launch processes and desk accessories. You can also use the Process Manager to alter the processing status of an application or to terminate your application. If you want a task to be executed after some specified amount of time has elapsed, you can use the Time Manager to schedule that task for later execution. The task can reschedule itself, so you can use the Time Manager to execute a routine repetitively. You can also use the Time Manager to calculate elapsed times and to synchronize events in the Macintosh computer. See the chapter “Time Manager” for details. The Vertical Retrace Manager allows you to schedule a task for execution during vertical retrace interrupts. Like Time Manager tasks, vertical retrace tasks can reschedule themselves so that they are executed repetitively. In general, you should use the Vertical Retrace Manager to handle repetitive

Reading notes: Headline spacing 'P R E F A C E' may be a layout artifact rather than a single word Final sentence is truncated mid-thought at 'handle repetitive'

Languages
English