16
DESIGN PRINCIPLES DESIGN PRINCIPLES MAC OS X MAC OS X

Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

Embed Size (px)

Citation preview

Page 1: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

DESIGN PRINCIPLESDESIGN PRINCIPLES

MAC OS XMAC OS X

Page 2: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

INNER DESIGN FEATURESINNER DESIGN FEATURES Pre-emptive multitasking and memory protection.Pre-emptive multitasking and memory protection. Designed to be portable.Designed to be portable. Includes its own software development toolsIncludes its own software development tools, most prominently , most prominently

an integrated development environment called Xcode. Xcode an integrated development environment called Xcode. Xcode provides interfaces to compilers that support several programming provides interfaces to compilers that support several programming languages including C, C++, Objective-C, and Java.languages including C, C++, Objective-C, and Java.

To permit a smooth transition from Mac OS 9 to Mac OS X, the To permit a smooth transition from Mac OS 9 to Mac OS X, the Carbon Application Programming InterfaceCarbon Application Programming Interface (API) was created. (API) was created. Applications written with Carbon can be executed natively on both Applications written with Carbon can be executed natively on both systems.systems.

Support the Java PlatformSupport the Java Platform as a "preferred software package"—in as a "preferred software package"—in practice this means that applications written in Java fit as neatly into practice this means that applications written in Java fit as neatly into the operating system as possible while still being cross-platform the operating system as possible while still being cross-platform compatible.compatible.

Many software packages written for the BSDs or Linux can be Many software packages written for the BSDs or Linux can be recompiled to run on it.recompiled to run on it.

Page 3: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

Aqua GUIAqua GUI – A fluid graphical user interface with – A fluid graphical user interface with water-like elements. water-like elements.

  

Anti-aliasing of widgets, text, graphics and window elements. Anti-aliasing of widgets, text, graphics and window elements. ColorSync color matching built into the core drawing engine, for print and ColorSync color matching built into the core drawing engine, for print and

multimedia professionals. multimedia professionals. Drop shadows around window and isolated text elements to provide a sense of Drop shadows around window and isolated text elements to provide a sense of

depth. depth. Full-color, scalable icons up to 512x512 pixels Full-color, scalable icons up to 512x512 pixels Human interface guidelines followed by almost all applications, giving them Human interface guidelines followed by almost all applications, giving them

consistent user interface and keyboard shortcuts. consistent user interface and keyboard shortcuts. New interface elements including sheets (document modal dialog boxes attached New interface elements including sheets (document modal dialog boxes attached

to specific windows) and drawers. to specific windows) and drawers. OpenGL composites windows onto the screen to allow hardware-accelerated OpenGL composites windows onto the screen to allow hardware-accelerated

drawing. This technology (introduced in version 10.2) is called Quartz Extreme. drawing. This technology (introduced in version 10.2) is called Quartz Extreme.

GUI FEATURESGUI FEATURES

Page 4: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

APPLICATION FEATURESAPPLICATION FEATURES QuartzQuartz's internal imaging model correlates well with the 's internal imaging model correlates well with the Portable Document FormatPortable Document Format (PDF) (PDF)

imaging model, making it easy to output PDF to multiple devices. PDF viewing is built in. imaging model, making it easy to output PDF to multiple devices. PDF viewing is built in. AutomatorAutomator – an application designed to create an automatic workflow for different tasks. – an application designed to create an automatic workflow for different tasks. DashboardDashboard – A full-screen group of small applications called desktop widgets that can be called – A full-screen group of small applications called desktop widgets that can be called

up and dismissed in one keystroke.up and dismissed in one keystroke. ExposéExposé – A feature which includes three functions to help accessibility between windows and – A feature which includes three functions to help accessibility between windows and

desktop. Its functions are to instantly display all open windows as thumbnails for easy navigation desktop. Its functions are to instantly display all open windows as thumbnails for easy navigation to different tasks, display all open windows as thumbnails from the current application, and hide to different tasks, display all open windows as thumbnails from the current application, and hide all windows to access the desktop.all windows to access the desktop.

FileVaultFileVault – Optional encryption of the user's files with Advanced Encryption Standard (AES). – Optional encryption of the user's files with Advanced Encryption Standard (AES). Front RowFront Row – A media viewer interface accessed by the Apple Remote. – A media viewer interface accessed by the Apple Remote. Global application servicesGlobal application services – spell and grammar checker, special characters palette, color – spell and grammar checker, special characters palette, color

picker, font chooser and dictionary. picker, font chooser and dictionary. Integrated Sync ServicesIntegrated Sync Services – A system which allows applications to access a centralized – A system which allows applications to access a centralized

extensible database for various elements of user data, including calendar and contact items. The extensible database for various elements of user data, including calendar and contact items. The operating system manages conflicting edits and data consistency. operating system manages conflicting edits and data consistency.

SpacesSpaces – Desktop organization tool which can create and manage multiple virtual desktops and – Desktop organization tool which can create and manage multiple virtual desktops and display them in an Exposé-like interface. display them in an Exposé-like interface.

Page 5: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

APPLICATION FEATURES APPLICATION FEATURES cont…cont…

Cover FlowCover Flow – is a three-dimensional graphical user interface included with iTunes, – is a three-dimensional graphical user interface included with iTunes, the Finder, and other Apple Inc. products for visually skimming through files and the Finder, and other Apple Inc. products for visually skimming through files and digital media libraries via cover artwork. digital media libraries via cover artwork.

Time MachineTime Machine – Automatic backup technology that allows users to view and restore – Automatic backup technology that allows users to view and restore previous versions of files and application data. previous versions of files and application data.

Screen SharingScreen Sharing – Mac OS X v10.5 has inbuilt screen sharing property which is very – Mac OS X v10.5 has inbuilt screen sharing property which is very useful in networking.useful in networking.

FinderFinder - is a file browser allowing quick access to all areas of the computer, which - is a file browser allowing quick access to all areas of the computer, which has been modified throughout subsequent releases of Mac OS X.has been modified throughout subsequent releases of Mac OS X.

Quick LookQuick Look - is part of Mac OS X Leopard's Finder. It allows for dynamic previews of - is part of Mac OS X Leopard's Finder. It allows for dynamic previews of files, including videos and multi-page documents, without opening their parent files, including videos and multi-page documents, without opening their parent applications. applications.

Spotlight search technologySpotlight search technology - is integrated into the Finder since Mac OS X Tiger, - is integrated into the Finder since Mac OS X Tiger, allows rapid real-time searches of: data files; mail messages; photos; and other allows rapid real-time searches of: data files; mail messages; photos; and other information based on item properties (Meta data) and/or content.information based on item properties (Meta data) and/or content.

The DockThe Dock - holds file and folder shortcuts as well as minimized windows. - holds file and folder shortcuts as well as minimized windows.

Page 6: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

Kernel modulesKernel modules

MAC OS XMAC OS X

Page 7: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

THE LOGICAL LAYERS…THE LOGICAL LAYERS…

Page 8: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

XNU: The KernelXNU: The Kernel

MACH.MACH.Berkeley Software Distribution(BSD).Berkeley Software Distribution(BSD). I/O KIT.I/O KIT.Driver Peripherals.Driver Peripherals.

The Mac OS X kernel is called XNU which is monolithic. It can be viewed as consisting of the following components:

The Mac OS X kernel is called XNU which is monolithic. It can be viewed as consisting of the following components:

Page 9: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

MACHMACHXNU's Mach component is based on Mach 3.0, although it's XNU's Mach component is based on Mach 3.0, although it's

not used as a microkernel. XNU's Mach is responsible not used as a microkernel. XNU's Mach is responsible for various low-level aspects of the system, such as: for various low-level aspects of the system, such as: Preemptive multitasking, including kernel threads (POSIX threads on Preemptive multitasking, including kernel threads (POSIX threads on

Mac OS X are implemented using kernel threads) Mac OS X are implemented using kernel threads) Protected memory Protected memory Virtual memory management Virtual memory management Inter-process communication Inter-process communication Interrupt management Interrupt management Real-time support Real-time support Kernel debugging support (the built-in low-level kernel debugger, ddb, is Kernel debugging support (the built-in low-level kernel debugger, ddb, is

part of XNU's Mach component, and so is kdp, a remote kernel part of XNU's Mach component, and so is kdp, a remote kernel debugging protocol implementation) debugging protocol implementation)

Console I/O Console I/O

Page 10: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

BSDBSD

Responsible for:Responsible for: process model. process model. User ids, permissions, basic security policies .User ids, permissions, basic security policies . POSIX API, BSD style system calls .POSIX API, BSD style system calls . TCP/IP stack, BSD sockets, firewall .TCP/IP stack, BSD sockets, firewall . VFS and file systems .VFS and file systems . System V IPC .System V IPC . Crypto framework. Crypto framework. Various synchronization mechanisms .Various synchronization mechanisms .

Page 11: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

I/O KITI/O KIT The object-oriented device driver framework of the XNU kernel.The object-oriented device driver framework of the XNU kernel. Uses a restricted subset of C++ (based on Embedded C++) as its Uses a restricted subset of C++ (based on Embedded C++) as its

programming language. This system is implemented by the libkern programming language. This system is implemented by the libkern library. Features of C++ that are not allowed in this subset include: library. Features of C++ that are not allowed in this subset include: Exceptions Exceptions Multiple inheritance Multiple inheritance Templates Templates RTTI (run-time type information), although I/O Kit has its own run-time RTTI (run-time type information), although I/O Kit has its own run-time

typing system .typing system . I/O Kit's implementation consists of three C++ libraries that are I/O Kit's implementation consists of three C++ libraries that are

present in the kernel and available to loadable drivers:present in the kernel and available to loadable drivers:

IOKit.framework, Kernel/libkern and Kernel/IOKit.IOKit.framework, Kernel/libkern and Kernel/IOKit. The I/O Kit includes a modular, layered run-time architecture that The I/O Kit includes a modular, layered run-time architecture that

presents an abstraction of the underlying hardware by capturing the presents an abstraction of the underlying hardware by capturing the dynamic relationships between the various hardware/software dynamic relationships between the various hardware/software components.components.

Page 12: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

I/O KIT FEATURESI/O KIT FEATURES Numerous device families (ATA/ATAPI, FireWire, Graphics, HID, Numerous device families (ATA/ATAPI, FireWire, Graphics, HID,

Network, PCI, USB, HID, ...) Network, PCI, USB, HID, ...) Object oriented abstractions of devices that can be shared Object oriented abstractions of devices that can be shared Plug-and-play and hot-plugging Plug-and-play and hot-plugging Power management Power management Preemptive multitasking, threading, symmetric multiprocessing, Preemptive multitasking, threading, symmetric multiprocessing,

memory protection and data management memory protection and data management Dynamic matching and loading of drivers (multiple bus types) Dynamic matching and loading of drivers (multiple bus types) A database for tracking and maintaining detailed information on A database for tracking and maintaining detailed information on

instantiated objects (the I/O Registry) instantiated objects (the I/O Registry) A database of all I/O Kit classes available on a system (the I/O A database of all I/O Kit classes available on a system (the I/O

Catalog) Catalog) An extensive API An extensive API Mechanisms/interfaces for applications and user-space drivers to Mechanisms/interfaces for applications and user-space drivers to

communicate with the I/O Kit communicate with the I/O Kit Driver stacking Driver stacking

Page 13: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

Driver PeripheralsDriver Peripherals

Kernel Extensions (KENTs).Kernel Extensions (KENTs).

PLATFORM EXPERT.PLATFORM EXPERT.

LIBKERN AND LIBSA.LIBKERN AND LIBSA.

Page 14: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

KENTsKENTs

I/O-Kit drivers are dynamically linked at runtime, I/O-Kit drivers are dynamically linked at runtime, as so-called “KEXTs”.as so-called “KEXTs”.

KEXT can not only link against the I/O-Kit KEXT can not only link against the I/O-Kit component, but also against other parts of the component, but also against other parts of the kernel. This way, filesystem and networking kernel. This way, filesystem and networking KEXTs (NKEs) are possible.KEXTs (NKEs) are possible.

Every KEXT, which typically resides in Every KEXT, which typically resides in /System/Library/Extensions, is a bundle, i.e. a /System/Library/Extensions, is a bundle, i.e. a subdirectory which contains the actual binary subdirectory which contains the actual binary and an XML description of dependencies and and an XML description of dependencies and the parts of the kernel it links against.the parts of the kernel it links against.

Page 15: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

PLATFORM EXPERTPLATFORM EXPERT The Platform Expert is an object that knows the type of platform that The Platform Expert is an object that knows the type of platform that

the system is running on.the system is running on. This nub then loads the correct platform specific driver, which This nub then loads the correct platform specific driver, which

further discovers the buses present on the system, registering a nub further discovers the buses present on the system, registering a nub for each bus found. The I/O Kit loads a matching driver for each bus for each bus found. The I/O Kit loads a matching driver for each bus nub, which discovers the devices connected to the bus, and so on.nub, which discovers the devices connected to the bus, and so on.

””nub“nub“ - an object that defines an access point and - an object that defines an access point and communication channel for a device (a bus, a disk drive or partition, communication channel for a device (a bus, a disk drive or partition, a graphics card, ...) or logical service (arbitration, driver matching, a graphics card, ...) or logical service (arbitration, driver matching, power management, ...).power management, ...).

Responsible for actions such as: Responsible for actions such as: Building the device tree. Building the device tree. Parse certain boot arguments.Parse certain boot arguments. Identify the machine (including processor and bus clock speeds). Identify the machine (including processor and bus clock speeds). Initialize a "user interface" to be used in case of kernel panics.Initialize a "user interface" to be used in case of kernel panics.

Page 16: Mac OS X - DESIGN PRINCIPLES AND KERNEL MODULES

LIBKERN AND LIBSALIBKERN AND LIBSA

LIBKERNLIBKERN Provides features such Provides features such

as: as: Dynamic object allocation, Dynamic object allocation,

construction, destruction construction, destruction (including data structures such (including data structures such as Arrays, Booleans, as Arrays, Booleans, Dictionaries, ...).Dictionaries, ...).

Certain atomic operations, Certain atomic operations, miscellaneous functions miscellaneous functions (bcmp(), memcmp(), (bcmp(), memcmp(), strlen(), ...).strlen(), ...).

Provisions for tracking the Provisions for tracking the number of current instances number of current instances for each class for each class

Ways to avoid the "Fragile Ways to avoid the "Fragile Base Class Problem".Base Class Problem".

LIBSALIBSA Provides fuctions for Provides fuctions for

miscellaneous purposes: miscellaneous purposes: binary searching.binary searching. symbol remangling, symbol remangling, Dgraphs.Dgraphs. CatalogsCatalogs kernel extension kernel extension

managementmanagement Sorting.Sorting. Patching vtablesPatching vtables etc. etc.