mach_msg_overwrite_trap
)and message formats are themselves abstracted in normal usage bythe Mach Interface Generator(MIG).MIG is used to compile procedural interfaces to the message-basedAPIs, based on descriptions of those APIs.mach_thread_self
, mach_task_self
,and mach_reply_port
.)vm_allocate
).The underlying virtual memory object is anonymous and backed by thedefault pager. Shared ranges of an address space may also be setup via inheritance. When new tasks are created, they are clonedfrom a parent. This cloning pertains to the underlying memory addressspace as well. Mapped portions of objects may be inherited as acopy, or as shared, or not at all, based on attributes associatedwith the mappings. Mach practices a form of delayed copy known as copy-on-write tooptimize the performance of inherited copies on task creation.mach_ipc
familyand the mach_msg
family.Within reason, both families may be used with any IPC object; however,the mach_ipc
calls arepreferred in new code. The mach_ipc
calls maintainstate information where appropriate in order to support the notionof a transaction. The mach_msg
callsare supported for legacy code but deprecated; they are stateless. mach_ipc_dispatch
,it repeatedly processes events coming in on the registered portset. These events could be an argument block from an RPCobject (as the results of a client’s call), a lock object beingtaken (as a result of some other thread’s releasing the lock),a notification or semaphore being posted, or a message coming infrom a traditional message queue. mach_msg_dispatch
.Some events imply a transaction during the lifetime of the callout.In the case of a lock, the state is the ownership of the lock. Whenthe callout returns, the lock is released. In the case of remoteprocedure calls, the state is the client’s identity, the argumentblock, and the reply port. When the callout returns, the reply issent.mach_ipc_dispatch
facilityis intended to support work loops.mach_timespec_t
.There are one or more clock objects, each defining a monotonicallyincreasing time value expressed in nanoseconds. The real-time clockis built in, and is the most important, but there may be other clocksfor other notions of time in the system. Clocks support operationsto get the current time, sleep for a given period, set an alarm(a notification that is sent at a given time), and so forth. mach_timespec_t
API is deprecatedin OS X. The newer and preferred API is based on timer objectsthat in turn use AbsoluteTime
asthe basic data type. AbsoluteTime
isa machine-dependent type, typically based on the platform-nativetime base. Routines are provided to convert AbsoluteTime
valuesto and from other data types, such as nanoseconds. Timer objectssupport asynchronous, drift-free notification, cancellation, andpremature alarms. They are more efficient and permit higher resolutionthan clocks.