众所周知,Mac OS X部分脱胎于BSD,特别是FreeBSD,主要是文件系统和NKE(Net Work Environment),但这二者有什么区别了,我们来看一篇文章(2006年更新,也就是说10.5适用)。
Differences between Mac OS X and BSD
Although the BSD portion of Mac OS X is primarily derived from FreeBSD, some changes have been made:
The
sbrk()
system call for memory management is deprecated. Its use is not recommended in Mac OS X.-
The Mac OS X runtime model uses a different object file format for executables and shared objects, and a different mechanism for executing some of those executables.
The primary native format is Mach-O. This format is supported by the dynamic link editor (dyld).
The PEF binary file format is supported by the Code Fragment Manager (CFM).
The kernel supports
execve()
with Mach-O binaries. Mapping and management of Mach-O dynamic shared libraries, as well as launching of PEF-based applications, are performed by user-space code. Mac OS X does not support memory-mapped devices through the
mmap()
function. (Graphic device support and other subsystems provide similar functionality, but using different APIs.) In Mac OS X, this interface should be done through user clients. See the Apple I/O Kit documents for additional information.The
swapon()
call is not supported;macx_swapon()
is the equivalent call from the Mach pager.The Unified Buffer Cache implementation in Mac OS X differs from that found in FreeBSD.
Mach provides a number of IPC primitives that are not traditionally found in UNIX. See “Boundary Crossings” for more information on Mach IPC. Some System V primitives are supported, but their use is discouraged in favor of POSIX equivalents.
Several changes have been made to the BSD security model to support single-user and multiple-administrator configurations, including the ability to disable ownership and permissions on a volume-by-volume basis.
The locking mechanism used throughout the kernel differs substantially from the mechanism used in FreeBSD.
The kernel extension mechanism used by Mac OS X is completely different. The Mac OS X driver layer, the I/O Kit, is an object-oriented driver stack written in C++. The general kernel programming interfaces, or KPIs, are used to write non-driver kernel extensions. These mechanisms are described more in "I/O Kit Overview" and KPI Reference, respectively.
In addition, several new features have been added that are specific to the Mac OS X (Darwin) implementation of BSD. These features are not found in FreeBSD.
-
enhancements to file-system buffer cache and file I/O clustering
adaptive and speculative read ahead
user-process controlled read ahead
time aging of the file-system buffer cache
-
enhancements to file-system support
implementation of Apple extensions for ISO-9660 file systems
multithreaded asynchronous I/O for NFS
addition of system calls to support semantics of Mac OS Extended (HFS+) file systems
additions to naming conventions for pathnames, as required for accessing multiple forks in Mac OS Extended file systems
注:Mac OS X的kernel可以说是由两部分构成:Mach(I/O kit,Driver)+BSD(filesystem,NKE)。