Table Of ContentMac OS X Internals
This page intentionally left blank
Mac OS X Internals
A Systems Approach
Amit Singh
Upper Saddle River, NJ • Boston (cid:129) Indianapolis (cid:129) San Francisco
New York (cid:129) Toronto (cid:129) Montreal (cid:129) London (cid:129) Munich (cid:129) Paris (cid:129) Madrid
Capetown (cid:129) Sydney (cid:129) Tokyo (cid:129) Singapore (cid:129) Mexico City
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and the publisher was aware
of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The author and publisher have taken care in the preparation of this book, but make no expressed or
implied warranty of any kind and assume no responsibility for errors or omissions. No liability is
assumed for incidental or consequential damages in connection with or arising out of the use of the
information or programs contained herein.
The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases
or special sales, which may include electronic versions and/or custom covers and content particular
to your business, training goals, marketing focus, and branding interests. For more information,
please contact:
U.S. Corporate and Government Sales, (800) 382-3419, corpsales@pearsontechgroup.com
For sales outside the United States, please contact:
International Sales, international@pearsoned.com
Visit us on the Web: www.awprofessional.com
Library of Congress Cataloging-in-Publication Data
Singh, Amit.
Mac OS X internals : a systems approach / Amit Singh.
p. cm.
Includes bibliographical references and index.
ISBN 0-321-27854-2 (hardback : alk. paper)
1. Mac OS. 2. Operating systems (Computers) 3. Macintosh (Computer)--Programming. I. Title.
QA76.76.O63S5645 2006
005.4'4682—dc22
2006014901
Copyright © 2007 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by
copyright, and permission must be obtained from the publisher prior to any prohibited reproduction,
storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical,
photocopying, recording, or likewise. For information regarding permissions, write to:
Pearson Education, Inc.
Rights and Contracts Department
75 Arlington Street, Suite 300
Boston, MA 02116
Fax: (617) 848-7047
ISBN 0-321-27854-2
Text printed in the United States on recycled paper at Courier Westford in Westford, Massachusetts.
4th Printing May 2010
iv
To my parents, Sharda and Amar Singh,
for teaching me everything I know about learning,
for giving me everything that I ever needed (or wanted) from them,
and for always being in my way without becoming an obstacle.
This page intentionally left blank
Contents
Preface xxv
Acknowledgments xxxi
About the Author xxxiii
Chapter 1 Origins of Mac OS X 1
1.1 Apple’s Quest for the Operating System 2
1.1.1 Star Trek 3
1.1.2 Raptor 4
1.1.3 NuKernel 4
1.1.4 TalOS 4
1.1.5 Copland 5
1.1.6 Gershwin 6
1.1.7 BeOS 7
1.1.8 Plan A 9
1.2 The NeXT Chapter 9
1.2.1 NEXTSTEP 10
1.2.2 OPENSTEP 13
1.3 The Mach Factor 15
1.3.1 Rochester’s Intelligent Gateway 16
1.3.2 Accent 17
1.3.3 Mach 18
1.3.4 MkLinux 23
1.3.5 Musical Names 24
vii
viii Contents
1.4 Strategies 24
1.4.1 Mac OS 8 and 9 25
1.4.2 Rhapsody 27
1.5 Toward Mac OS X 31
1.5.1 Mac OS X Server 1.x 31
1.5.2 Mac OS X Developer Previews 31
1.5.3 Mac OS X Public Beta 34
1.5.4 Mac OS X 10.x 36
Chapter 2 An Overview of Mac OS X 43
2.1 Firmware 46
2.2 Bootloader 46
2.3 Darwin 46
2.3.1 Darwin Packages 47
2.3.2 The Benefits of Darwin 47
2.3.3 Darwin and Mac OS X 48
2.4 The xnu Kernel 48
2.4.1 Mach 49
2.4.2 BSD 50
2.4.3 The I/O Kit 53
2.4.4 The libkern Library 54
2.4.5 The libsa Library 55
2.4.6 The Platform Expert 56
2.4.7 Kernel Extensions 57
2.5 A User-Space View of the File System 57
2.5.1 File System Domains 57
2.5.2 The /System/Library/ Directory 59
2.6 The Runtime Architecture 61
2.6.1 Mach-O Files 62
2.6.2 Fat Binaries 66
2.6.3 Linking 67
2.7 The C Library 74
2.8 Bundles and Frameworks 76
2.8.1 Bundles 76
2.8.2 Property List Files 81
2.8.3 Frameworks 82
2.8.4 Prebinding 86
2.9 Core Services 89
Contents ix
2.10 Application Services 90
2.10.1 Graphics and Multimedia Services 91
2.10.2 Other Application Services 101
2.11 Application Environments 101
2.11.1 BSD 102
2.11.2 The X Window System 103
2.11.3 Carbon 103
2.11.4 Cocoa 107
2.11.5 WebObjects 113
2.11.6 Java 113
2.11.7 QuickTime 114
2.11.8 Classic 114
2.11.9 Rosetta 116
2.12 User Interface 117
2.12.1 Visual Effects 118
2.12.2 Resolution-Independent User Interface 118
2.12.3 Productivity Features 119
2.12.4 Universal Access Support 120
2.13 Programming 121
2.13.1 Xcode 122
2.13.2 Compilers and Libraries 124
2.13.3 Interpreters 125
2.13.4 Tools 129
2.14 Security 131
2.14.1 Kernel-Space Security 133
2.14.2 User-Space Security 134
2.14.3 System Administration 139
2.14.4 The Auditing System 143
2.15 Mac OS X Server 145
2.15.1 Xgrid 146
2.15.2 Xsan 150
2.16 Networking 153
Chapter 3 Inside an Apple 155
3.1 The Power Mac G5 156
3.1.1 The U3H System Controller 157
3.1.2 The K2 I/O Device Controller 159
3.1.3 PCI-X and PCI Express 159