MacOSX-by-Matt-Grady-Mike-OConner-Justin-Rains-2005

Download Report

Transcript MacOSX-by-Matt-Grady-Mike-OConner-Justin-Rains-2005

Mac OS X
CS-450-1: Operating Systems
Fall 2005
Matt Grady – Mike O’Connor – Justin Rains
Overview: General
• Tenth version of the Mac OS developed by Apple
• Independent of all previous versions of Mac OS
• Noticeable surface changes
– Brand new GUI “Aqua,” a radical departure from previous
versions
– Addition of the Dock, an application launcher
• Introduction of open-source Darwin
– Mach forms the core of XNU kernel
– Built on BSD Unix foundation
Overview: Tiger
• Current version of OS X, 10.4
• Changes for the general user
– Spotlight: powerful meta-data search tool
– Dashboard: mini-application layer
• Additions “under the hood”
– Startup daemon ‘launchd’ allows for quick boots
– Kernel resource locking optimization
– Core Image, Core Data, Core Video
CPU Scheduling
• Mach holds four different priority queues
–
–
–
–
Normal
System High
Kernel Mode Only
Real Time
• Non-kernel mode only threads’ priorities constantly
changing
• Prevents bottlenecking by giving resource-intensive
threads lower priorities
Processor Modes
• Supervisor Mode or User Mode
– Supervisor calls made through Mach
– Message Passing (no trap table)
• Interrupt Context not necessary
– Uses a generic interrupt handling thread
– Spends minimal time in supervisor mode
– Minimal latency using this approach.
• I/O Kit
– Part of Darwin that handles device drivers
– Has all the support for multi-processor machines (SMP)
Process Management
• Multiprocessor Systems
– Splits processes into independent threads
– Takes advantage of critical sections (regions)
– Multiprocessing Services API
• Features, code, and support for multiprocessor functionality
(semaphores, critical regions, processor availability, etc)
• Allows programmers to set relative priority of tasks
• Process Tracking
– Similar to Mach 3.0
– Mach Tasks
– Mach Ports
File Management
• Provides support for numerous file systems
– UFS, ISO 9660, MS-DOS, SMB, NFS
– HFS and HFS+ (extended)
•
•
•
•
Preferred file system
64 bit length files
32 bit allocation table (HFS was 16 – limits disk size drastically)
Not case sensitive
• Virtual File System
– On UFS, derived from BSD
– Allows for booting from other file systems (need kernel extensions)
– Vnode
• Data structure for directories and files
• Vnode Operations (VOP) allows access and provide operations
File Management
• Carbon
– Default Volume type is HFS+
– Includes File Manager subsystem
•
•
•
•
•
•
•
•
•
•
•
Provides functionality for manipulating directories and files
Accessing Information about Files and Directories
Allocating File Blocks
Controlling Login and Directory
AccessCopying and Moving Files
Creating a File System Reference
Creating and Deleting Forks
Creating and Deleting Directories
Creating File System Specifications
Creating and Deleting Files
Getting and Setting Volume Information
Memory Management
• Apple’s memory model is based on the one used in the
Mach v3.0 kernel
• Uses virtual memory with the working set algorithm for
determining page faults
• In addition, Translation Lookaside Buffers, page tables,
and other techniques are implemented as hardware
specific
• RAM is considered a cache for virtual memory –
processes are initially loaded into virtual memory and
pages are only brought into RAM as needed
Memory Management
•
At the base level, memory is paged
•
Above that level is the Memory Object, which may contain a page, a set of
pages, a stack, or a file
•
A Virtual Memory (VM) Object is a collection of memory objects
•
A Memory Map is the total collection of VM objects for a process
•
The Virtual Memory (VM) system manages the VM objects, while a
subordinate, machine dependent, Process Mapping system (pmap) handles
the actual page faults
•
When two or more processes refer to the same page(s), a Shadow VM
object is created, which is a pointer to the original VM object that actually
contains the data
•
Universal Page Lists (UPL) are data structures used to communicate with
the VM system. A UPL is initialized with data from a VM object, the data is
altered, and the UPL is forced back on the VM object
Memory Management
•
There are two types of page faults: hard and soft
•
A hard page fault is the usual, where a page is not RAM, but is needed
•
A soft page fault is when the needed page is already in RAM, but does not
belong to the calling process’s memory space. In this case a shadow VM
object is created
•
Shadow VM objects use “copy-on-write”, which means that the shadow VM
object continues to point to the target VM object until a write is attempted, at
which point the target pages within the VM object are copied
•
The VM system maintains a “free list”, an “inactive list”, and an “active list”
of RAM. The system attempts to maintain a certain number of pages in the
free list by swapping pages in the inactive list out.
Deadlock
•
OS X does not seem to have any standard strategies for dealing with
deadlock. It is essentially left up to the application programmer to work out
the bugs which may cause deadlock
•
One strategy listed was to try to minimize the amount of a resource that
could be contested at any one time. For example, break one large lock,
which refers to a list of buffers, into several smaller locks for each buffer
•
It is also recommended that critical sections of code be kept to a minimum
•
Buffers may be eliminated, and thereby the possibility for their contention,
by using InterProcess Communication (IPC), which is a kernel function that
directly copies data from one process to another
•
Apple mentions using a total order for read-write locks, but refers to this
technique as “rather extreme”
Summary
• OS X v10.4 is Apple’s current OS for the Mac
• Designed for use by home users and creative
professionals
• Built on open-source, very stable Darwin core