OS X System Programming
Duration: 3-5 days

Back to course list Home
Synopsis This course covers the architecture of OS X from the ground up. OS X is the operating system behind Apple's Macs, iPhones, and iPads. Students will become familiar with OS X's layered architecture, from the core of Darwin (including an overview of the XNU kernel), through the POSIX interfaces and BSD system calls, and up to the various core frameworks. This course also introduces Objective-C, the language of choice for framework-enabled development.

Note: This code does not discuss GUI development in depth, and only touches upon it. It does, however, cover most other aspects of programming, applicable to OS X in both its Mac and iPhone ("iOS") flavors
Target Audience OS X developers, interested in getting to know Apple's Mac OS X. Mac developers and iPhone developers
Prerequisites
Objectives
  • Describe the functions and architecture of OS X
  • Create a fully functional OS X Cocoa application
  • Become comfortable with Objective-C 2.0
  • Create a POSIX compliant C or Objective-C application
  • Use OS X system tools
  • Use XCode and the amazingly powerful developer tools (Shark, Instruments, etc)
Exercises This course has optional exercises, though they may take up to 40% additional time.
Modules
1. Introduction
1 hours
Explaining the history and evolution of OS X, with emphasis on its NeXTSTEP/Rhapsody origin. A summary of technological features in each of the OS versions, focusing in depth on features in Leopard (10.5) and Snow Leopard (10.6.x)
  • What is OS X?
    • NeXTSTEP origins
      • OS X versions
        • Important features in each OS
          2. OS X architecture
          2 hours
          An overview of the OS X layered architecture, top to bottom. From the "User Experience" layer (the Aqua Window Manager), to the XNU kernel. We discuss:
          • OS X architectural layers
            • Application Frameworks - Cocoa, Carbon and Java
              • Core Frameworks - Core Audio/Video/.. and Core Foundation
                • Darwin - the UNIX shell
                  • XNU - The Mach/BSD hybrid Kernel
                    • I/O Kit - The Device Driver framework
                    • How is iOS different?
                      • OS X on ARM (iPhone) and Apple SOC (iPad/iPhone 4) architectures
                        • Springboard and backboardd
                          • lockdown and the house keeping daemons
                            • Jailbroken iOS
                            3. OS X is UN*X
                            2 hours
                            Detailed discussion of OS X Darwin environment, its similarities and differences from traditional UN*X systems:
                            • The standard UN*X Filesystem
                              • OS X additional directories
                                • OS X binaries (Mach-O) and binutils
                                  • OS X processes
                                    • Quick overview of useful command line utilities
                                      4. Mac Hardware
                                      0.5 hours
                                      Brief overview of Apple's ever changing hardware landscape. Focusing on all Mac models, in their past and current incarnations:
                                      • Models:
                                        • iMac
                                          • MacBook
                                            • MacBook Pro
                                              • Mac Mini
                                                • Mac Pro
                                                • System Profiler
                                                  • I/O Registry Explorer
                                                    5. The Mac Boot Sequence
                                                    2 hours
                                                    This module discusses the boot sequence on Mac hardware. Contrary to standard PCs, which use the Basic Input/Output System (BIOS), Mac hardware uses (on x86/x64) Intel's Extensible Firmware Interface (EFI). We discuss the boot sequence, from the second the computer is turned on, including:
                                                    • The EFI architecture
                                                      • EFI vs. BIOS
                                                        • EFI runtime services
                                                          • EFI protocols
                                                          • Booting the Kernel
                                                            • User Mode boot: Init (pre 10.4) and launchD
                                                              • Daemons and Agents
                                                                • Adding Custom Daemons agents
                                                                  • Startup Items
                                                                  6. Introducing - XCode
                                                                  2 hours
                                                                  XCode is Apple's (still) free development environment for OS X and for "iOS" (iPhone/iPad). More than a standard IDE, it comes packed with many powerful tools for performance and diagnostics. We discuss the environment, as well as those tools:
                                                                  • XCode - writing a sample project in C, C++, and/or Objective C
                                                                    • The Performance tools:
                                                                      • Instruments
                                                                        • Shark
                                                                          • ...


                                                                          Exercises include:
                                                                          • Profiling an application with Instruments and Shark
                                                                          7. POSIX threads on OS X
                                                                          1-2 hours
                                                                          Discussing the OS X implementation of POSIX threads. We explain POSIX threads in varying level of detail (depending on past student experience). We demonstrate a simple multi-threaded exercise, with basic synchronization mechanisms (Mutexes, rwlocks, and condition variables)

                                                                          Exercises include:
                                                                          • Creating and profiling a sample multithreaded application demonstrating full pthread_API
                                                                          8. Alternative to Threads
                                                                          2 hours
                                                                          Introducing OS X's latest and greatest features in Snow Leopard (10.6):
                                                                          • Why seek alternatives?
                                                                            • The Grand Central Dispatcher
                                                                              • Blocks and functions
                                                                                • Dispatcher Queues
                                                                                  • Completion Blocks
                                                                                    • Dispatch sources
                                                                                    • Open CL - Truly parallel programming on CPUs and GPUs
                                                                                      • What is Open CL?
                                                                                        • Writing your first Open CL program
                                                                                        9. Network programming in OS X
                                                                                        3 hours
                                                                                        Contrasting the traditional BSD socket API with the OS X CFNetwork wrappers
                                                                                        • Socket Programming - refresher
                                                                                          • CFNetwork and CFSocket
                                                                                            • NSURL
                                                                                              • WebKit
                                                                                                *. Introduction to Objective-C (Optional)
                                                                                                3 hours
                                                                                                Introduction to Objective-C 2.0, with the aim of getting the student to be able to read and decipher sometimes-not-so-easy-to-read Objective-C code samples.

                                                                                                Exercises include:
                                                                                                • Some quick Objective-C samples - from "Hello, world", to a fully working Cocoa application