95
Multiprocessing Services Reference

Apple manual

Embed Size (px)

DESCRIPTION

As title

Citation preview

Page 1: Apple manual

Multiprocessing Services Reference

Page 2: Apple manual

Contents

Multiprocessing Services Reference 6Overview 6Functions by Task 6

Determining Multiprocessing Services And Processor Availability 6Creating and Handling Message Queues 7Creating and Handling Semaphores 7Creating and Scheduling Tasks 7Handling Critical Regions 8Handling Event Groups 8Handling Kernel Notifications 9Accessing Per-Task Storage Variables 9Memory Allocation Functions 10Remote Calling Functions 10Timer Services Functions 10Exception Handling Functions 11Debugger Support Functions 11

Functions 11_MPIsFullyInitialized 11

Callbacks 12MPRemoteProcedure 12TaskProc 12

Data Types 13MPAddressSpaceID 13MPAddressSpaceInfo 13MPAreaID 14MPCoherenceID 14MPConsoleID 15MPCpuID 15MPCriticalRegionID 15MPCriticalRegionInfo 16MPEventFlags 16MPEventID 16MPEventInfo 17MPExceptionKind 17

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

2

Page 3: Apple manual

MPNotificationID 17MPNotificationInfo 18MPOpaqueID 18MPOpaqueIDClass 19MPPageSizeClass 19MPProcessID 19MPQueueID 19MPQueueInfo 20MPSemaphoreCount 20MPSemaphoreID 21MPSemaphoreInfo 21MPTaskID 21MPTaskInfo 22MPTaskInfoVersion2 24MPTaskStateKind 24MPTaskWeight 25MPTimerID 25TaskStorageIndex 25TaskStorageValue 26

Constants 26Allocation constants 26Task IDs 26Data Structure Version Constants 27Values for the MPOpaqueIDClass type 28Memory Allocation Alignment Constants 30Memory Allocation Option Constants 32MPDebuggerLevel 33Library Version Constants 33Remote Call Context Option Constants 34Task Creation Options 35Task Exception Disposal Constants 36Task Information Structure Version Constant 37Task Run State Constants 38Task State Constants 38Timer Duration Constants 40Timer Option Masks 40

Result Codes 41Gestalt Constants 42

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

3

Contents

Page 4: Apple manual

Deprecated Multiprocessing Services Functions 43Deprecated in OS X v10.7 43

MPAllocate 43MPAllocateAligned 43MPAllocateTaskStorageIndex 45MPArmTimer 45MPBlockClear 46MPBlockCopy 47MPCancelTimer 48MPCauseNotification 49MPCreateCriticalRegion 50MPCreateEvent 50MPCreateNotification 51MPCreateQueue 52MPCreateSemaphore 52MPCreateTask 53MPCreateTimer 55MPCurrentTaskID 56MPDataToCode 57MPDeallocateTaskStorageIndex 57MPDelayUntil 58MPDeleteCriticalRegion 59MPDeleteEvent 59MPDeleteNotification 60MPDeleteQueue 61MPDeleteSemaphore 61MPDeleteTimer 62MPDisposeTaskException 63MPEnterCriticalRegion 63MPExit 64MPExitCriticalRegion 65MPExtractTaskState 66MPFree 67MPGetAllocatedBlockSize 67MPGetNextCpuID 68MPGetNextTaskID 69MPGetTaskStorageValue 69MPModifyNotification 70MPModifyNotificationParameters 71

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

4

Contents

Page 5: Apple manual

MPNotifyQueue 72MPProcessors 73MPProcessorsScheduled 73MPRegisterDebugger 74MPRemoteCall 75MPRemoteCallCFM 76MPSetEvent 77MPSetExceptionHandler 78MPSetQueueReserve 78MPSetTaskState 79MPSetTaskStorageValue 81MPSetTaskWeight 81MPSetTimerNotify 82MPSignalSemaphore 84MPTaskIsPreemptive 84MPTerminateTask 85MPThrowException 87MPUnregisterDebugger 88MPWaitForEvent 88MPWaitOnQueue 89MPWaitOnSemaphore 91MPYield 91

Deprecated in OS X v10.8 92MPSetTaskType 92

Document Revision History 94

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

5

Contents

Page 6: Apple manual

Framework CoreServices/CoreServices.h

Companion guide Multiprocessing Services Programming Guide

Declared in Multiprocessing.h

MultiprocessingInfo.h

OverviewMultiprocessing Services is an API that lets you create preemptive tasks in your application that can run onone or more microprocessors. Unlike the cooperative threads created by the Thread Manager, MultiprocessingServices automatically divides processor time among the available tasks, so that no particular task canmonopolize the system. This document is relevant to you if you want to add multitasking capability to yourMac OS applications.

In OS X, Carbon supports Multiprocessing Services with the following restrictions:

● Debugging functions are not implemented. Use the mach APIs provided by the system to implementdebugging services.

● Opaque notification IDs are local to your process; they are not globally addressable across processes.

● Global memory allocation is not supported.

Functions by Task

Determining Multiprocessing Services And Processor Availability

_MPIsFullyInitialized (page 11)

Indicates whether Multiprocessing Services is available for use.

MPGetNextCpuID (page 68) Deprecated in OS X v10.7Obtains the next CPU ID in the list of physical processors of the specified memory coherence group.

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

6

Multiprocessing Services Reference

Page 7: Apple manual

MPProcessors (page 73) Deprecated in OS X v10.7Returns the number of processors on the host computer.

MPProcessorsScheduled (page 73) Deprecated in OS X v10.7Returns the number of active processors available on the host computer.

Creating and Handling Message Queues

MPCreateQueue (page 52) Deprecated in OS X v10.7Creates a message queue.

MPDeleteQueue (page 61) Deprecated in OS X v10.7Deletes a message queue.

MPNotifyQueue (page 72) Deprecated in OS X v10.7Sends a message to the specified message queue.

MPSetQueueReserve (page 78) Deprecated in OS X v10.7Reserves space for messages on a specified message queue.

MPWaitOnQueue (page 89) Deprecated in OS X v10.7Obtains a message from a specified message queue.

Creating and Handling Semaphores

MPCreateSemaphore (page 52) Deprecated in OS X v10.7Creates a semaphore.

MPDeleteSemaphore (page 61) Deprecated in OS X v10.7Removes a semaphore.

MPSignalSemaphore (page 84) Deprecated in OS X v10.7Signals a semaphore.

MPWaitOnSemaphore (page 91) Deprecated in OS X v10.7Waits on a semaphore

Creating and Scheduling Tasks

MPCreateTask (page 53) Deprecated in OS X v10.7Creates a preemptive task.

Multiprocessing Services ReferenceFunctions by Task

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

7

Page 8: Apple manual

MPCurrentTaskID (page 56) Deprecated in OS X v10.7Obtains the task ID of the currently-executing preemptive task

MPExit (page 64) Deprecated in OS X v10.7Allows a task to terminate itself

MPGetNextTaskID (page 69) Deprecated in OS X v10.7Obtains the next task ID in the list of available tasks.

MPSetTaskWeight (page 81) Deprecated in OS X v10.7Assigns a relative weight to a task, indicating how much processor time it should receive compared toother available tasks.

MPTaskIsPreemptive (page 84) Deprecated in OS X v10.7Determines whether a task is preemptively scheduled.

MPTerminateTask (page 85) Deprecated in OS X v10.7Terminates an existing task.

MPYield (page 91) Deprecated in OS X v10.7Allows a task to yield the processor to another task.

MPSetTaskType (page 92) Deprecated in OS X v10.8Sets the type of the task.

Handling Critical Regions

MPCreateCriticalRegion (page 50) Deprecated in OS X v10.7Creates a critical region object.

MPDeleteCriticalRegion (page 59) Deprecated in OS X v10.7Removes the specified critical region object.

MPEnterCriticalRegion (page 63) Deprecated in OS X v10.7Attempts to enter a critical region.

MPExitCriticalRegion (page 65) Deprecated in OS X v10.7Exits a critical region.

Handling Event Groups

MPCreateEvent (page 50) Deprecated in OS X v10.7Creates an event group.

Multiprocessing Services ReferenceFunctions by Task

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

8

Page 9: Apple manual

MPDeleteEvent (page 59) Deprecated in OS X v10.7Removes an event group.

MPSetEvent (page 77) Deprecated in OS X v10.7Merges event flags into a specified event group.

MPWaitForEvent (page 88) Deprecated in OS X v10.7Retrieves event flags from a specified event group.

Handling Kernel Notifications

MPCauseNotification (page 49) Deprecated in OS X v10.7Signals a kernel notification.

MPCreateNotification (page 51) Deprecated in OS X v10.7Creates a kernel notification

MPDeleteNotification (page 60) Deprecated in OS X v10.7Removes a kernel notification.

MPModifyNotification (page 70) Deprecated in OS X v10.7Adds a simple notification to a kernel notification.

MPModifyNotificationParameters (page 71) Deprecated in OS X v10.7

Accessing Per-Task Storage Variables

MPAllocateTaskStorageIndex (page 45) Deprecated in OS X v10.7Returns an index number to access per-task storage.

MPDeallocateTaskStorageIndex (page 57) Deprecated in OS X v10.7Frees an index number used to access per-task storage

MPGetTaskStorageValue (page 69) Deprecated in OS X v10.7Gets the storage value stored at a specified index number.

MPSetTaskStorageValue (page 81) Deprecated in OS X v10.7Sets the storage value for a given index number.

Multiprocessing Services ReferenceFunctions by Task

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

9

Page 10: Apple manual

Memory Allocation Functions

MPAllocate (page 43) Deprecated in OS X v10.7Allocates a nonrelocatable memory block. (Deprecated. Use MPAllocateAligned instead.)

MPAllocateAligned (page 43) Deprecated in OS X v10.7Allocates a nonrelocatable memory block.

MPBlockClear (page 46) Deprecated in OS X v10.7Clears a block of memory.

MPBlockCopy (page 47) Deprecated in OS X v10.7Copies a block of memory.

MPDataToCode (page 57) Deprecated in OS X v10.7Designates the specified block of memory as executable code.

MPFree (page 67) Deprecated in OS X v10.7Frees memory allocated by MPAllocateAligned.

MPGetAllocatedBlockSize (page 67) Deprecated in OS X v10.7Returns the size of a memory block.

Remote Calling Functions

MPRemoteCall (page 75) Deprecated in OS X v10.7Calls a non-reentrant function and blocks the current task.

MPRemoteCallCFM (page 76) Deprecated in OS X v10.7Calls a non-reentrant function and blocks the current task.

Timer Services Functions

MPArmTimer (page 45) Deprecated in OS X v10.7Arms the timer to expire at a given time.

MPCancelTimer (page 48) Deprecated in OS X v10.7Cancels an armed timer.

MPCreateTimer (page 55) Deprecated in OS X v10.7Creates a timer.

MPDelayUntil (page 58) Deprecated in OS X v10.7Blocks the calling task until a specified time.

Multiprocessing Services ReferenceFunctions by Task

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

10

Page 11: Apple manual

MPDeleteTimer (page 62) Deprecated in OS X v10.7Removes a timer.

MPSetTimerNotify (page 82) Deprecated in OS X v10.7Sets the notification information associated with a timer.

Exception Handling Functions

MPDisposeTaskException (page 63) Deprecated in OS X v10.7Removes a task exception.

MPExtractTaskState (page 66) Deprecated in OS X v10.7Extracts state information from a suspended task.

MPSetExceptionHandler (page 78) Deprecated in OS X v10.7Sets an exception handler for a task.

MPSetTaskState (page 79) Deprecated in OS X v10.7Sets state information for a suspended task.

MPThrowException (page 87) Deprecated in OS X v10.7Throws an exception to a specified task.

Debugger Support Functions

MPRegisterDebugger (page 74) Deprecated in OS X v10.7Registers a debugger.

MPUnregisterDebugger (page 88) Deprecated in OS X v10.7Unregisters a debugger.

Functions

_MPIsFullyInitialized

Indicates whether Multiprocessing Services is available for use.

Boolean _MPIsFullyInitialized (void

);

Multiprocessing Services ReferenceFunctions

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

11

Page 12: Apple manual

Return ValueIf true, Multiprocessing Services is available for use; otherwise, false.

Declared inMultiprocessing.h

Callbacks

MPRemoteProcedure

Defines a remote procedure call.

typedef void* (*MPRemoteProcedure) (void *parameter

);

For example, this is how you would declare the application-defined function if you were to name the functionMyRemoteProcedure:

void* MyRemoteProcedure (void *parameter

);

Parametersparameter

A pointer to the application-defined value you passed to the function MPRemoteCallCFM (page 76). Forexample, this value could point to a data structure or a memory location.

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

TaskProc

Defines the entry point of a task.

typedef OSStatus (*TaskProc) (

Multiprocessing Services ReferenceCallbacks

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

12

Page 13: Apple manual

void *parameter);

For example, this is how you would declare the application-defined function if you were to name the functionMyTaskProc:

OSStatus MyTaskProc (void *parameter

);

Parametersparameter

A pointer to the application-defined value you passed to the function MPCreateTask (page 53). Forexample, this value could point to a data structure or a memory location.

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

Data Types

MPAddressSpaceID

typedef struct OpaqueMPAddressSpaceID * MPAddressSpaceID;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPAddressSpaceInfo

struct MPAddressSpaceInfo {PBVersion version;MPProcessID processID;MPCoherenceID groupID;ItemCount nTasks;

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

13

Page 14: Apple manual

UInt32 vsid[16];};typedef struct MPAddressSpaceInfo MPAddressSpaceInfo;

AvailabilityAvailable in OS X v10.1 and later.

Declared inMultiprocessingInfo.h

MPAreaID

typedef struct OpaqueMPAreaID * MPAreaID;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPCoherenceID

Represents a memory coherence group.

typedef struct OpaqueMPCoherenceID * MPCoherenceID;

DiscussionA coherence group is the set of processors and other bus controllers that have cache-coherent access tomemory. Mac OS 9 defines only one coherence group, which is all the processors that can access internalmemory (RAM). Other coherence groups are possible; for example, a PCI card with its own memory andprocessors can comprise a coherence group.

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

14

Page 15: Apple manual

MPConsoleID

typedef struct OpaqueMPConsoleID * MPConsoleID;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPCpuID

Represents a CPU ID.

typedef struct OpaqueMPCpuID * MPCpuID;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPCriticalRegionID

Represents a critical region ID, which Multiprocessing Services uses to manipulate critical regions.

typedef struct OpaqueMPCriticalRegionID * MPCriticalRegionID;

DiscussionYou obtain a critical region ID by calling the function MPCreateCriticalRegion (page 50).

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

15

Page 16: Apple manual

MPCriticalRegionInfo

struct MPCriticalRegionInfo {PBVersion version;MPProcessID processID;OSType regionName;ItemCount nWaiting;MPTaskID waitingTaskID;MPTaskID owningTask;ItemCount count;

};typedef struct MPCriticalRegionInfo MPCriticalRegionInfo;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessingInfo.h

MPEventFlags

Represents event information for an event group.

typedef UInt32 MPEventFlags;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPEventID

Represents an event group ID, which Multiprocessing Services uses to manipulate event groups.

typedef struct OpaqueMPEventID * MPEventID;

DiscussionYou obtain an event group ID by calling the function MPCreateEvent (page 50).

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

16

Page 17: Apple manual

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPEventInfo

struct MPEventInfo {PBVersion version;MPProcessID processID;OSType eventName;ItemCount nWaiting;MPTaskID waitingTaskID;MPEventFlags events;

};typedef struct MPEventInfo MPEventInfo;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessingInfo.h

MPExceptionKind

Represents the kind of exception thrown.

typedef UInt32 MPExceptionKind;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPNotificationID

Represents a notification ID, which Multiprocessing Services uses to manipulate kernel notifications.

typedef struct OpaqueMPNotificationID * MPNotificationID;

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

17

Page 18: Apple manual

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPNotificationInfo

struct MPNotificationInfo {PBVersion version;MPProcessID processID;OSType notificationName;MPQueueID queueID;void * p1;void * p2;void * p3;MPEventID eventID;MPEventFlags events;MPSemaphoreID semaphoreID;

};typedef struct MPNotificationInfo MPNotificationInfo;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessingInfo.h

MPOpaqueID

Represents a generic notification ID (that is, an ID that could be a queue ID, event ID, kernel notification ID, orsemaphore ID).

typedef struct OpaqueMPOpaqueID * MPOpaqueID;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

18

Page 19: Apple manual

MPOpaqueIDClass

typedef UInt32 MPOpaqueIDClass;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPPageSizeClass

typedef UInt32 MPPageSizeClass;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPProcessID

Represents a process ID.

typedef struct OpaqueMPProcessID * MPProcessID;

DiscussionNote that this process ID is identical to the process ID (or context ID) handled by the Code Fragment Manager.

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPQueueID

Represents a queue ID, which Multiprocessing Services uses to manipulate message queues.

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

19

Page 20: Apple manual

typedef struct OpaqueMPQueueID * MPQueueID;

DiscussionYou obtain a queue ID by calling the function MPCreateQueue (page 52).

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPQueueInfo

struct MPQueueInfo {PBVersion version;MPProcessID processID;OSType queueName;ItemCount nWaiting;MPTaskID waitingTaskID;ItemCount nMessages;ItemCount nReserved;void * p1;void * p2;void * p3;

};typedef struct MPQueueInfo MPQueueInfo;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessingInfo.h

MPSemaphoreCount

Represents a semaphore count.

typedef ItemCount MPSemaphoreCount;

AvailabilityAvailable in OS X v10.0 and later.

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

20

Page 21: Apple manual

Declared inMultiprocessing.h

MPSemaphoreID

Represents a semaphore ID, which Multiprocessing Services uses to manipulate semaphores.

typedef struct OpaqueMPSemaphoreID * MPSemaphoreID;

DiscussionYou obtain a semaphore ID by calling the function MPCreateSemaphore (page 52).

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPSemaphoreInfo

struct MPSemaphoreInfo {PBVersion version;MPProcessID processID;OSType semaphoreName;ItemCount nWaiting;MPTaskID waitingTaskID;ItemCount maximum;ItemCount count;

};typedef struct MPSemaphoreInfo MPSemaphoreInfo;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessingInfo.h

MPTaskID

Represents a task ID.

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

21

Page 22: Apple manual

typedef struct OpaqueMPTaskID * MPTaskID;

DiscussionYou obtain a task ID by calling the function MPCreateTask (page 53).

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPTaskInfo

Contains information about a task.

struct MPTaskInfo {PBVersion version;OSType name;OSType queueName;UInt16 runState;UInt16 lastCPU;UInt32 weight;MPProcessID processID;AbsoluteTime cpuTime;AbsoluteTime schedTime;AbsoluteTime creationTime;ItemCount codePageFaults;ItemCount dataPageFaults;ItemCount preemptions;MPCpuID cpuID;MPOpaqueID blockedObject;MPAddressSpaceID spaceID;LogicalAddress stackBase;LogicalAddress stackLimit;LogicalAddress stackCurr;

};typedef struct MPTaskInfo MPTaskInfo;

Fieldsversion

The version of this data structure.

nameThe name of the task.

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

22

Page 23: Apple manual

queueNameA four-byte code indicating the status of the queue waiting on the task.

runStateThe current state of the task (running, ready, or blocked).

lastCPUThe address of the last processor that ran this task.

weightThe weighting assigned to this task.

processIDThe ID of the process that owns this task.

cpuTimeThe accumulated CPU time used by the task.

schedTimeThe time when the task was last scheduled.

creationTimeThe time when the task was created.

codePageFaultsThe number of page faults that occurred during code execution.

dataPageFaultsThe number of page faults that occurred during data access.

preemptionsThe number of times this task was preempted.

cpuIDThe ID of the last processor that ran this task.

blockedObjectReserved for use by OS X.

spaceIDAddress space ID of this task.

stackBaseThe lowest memory address of the task’s stack.

stackLimitThe highest memory address of the task’s stack.

stackCurrThe current stack address.

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

23

Page 24: Apple manual

DiscussionIf you specify the kMPTaskStateTaskInfo constant when calling the function MPExtractTaskState (page

66) , Multiprocessing Services returns state information in an MPTaskInfo structure.

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPTaskInfoVersion2

struct MPTaskInfoVersion2 {PBVersion version;OSType name;OSType queueName;UInt16 runState;UInt16 lastCPU;UInt32 weight;MPProcessID processID;AbsoluteTime cpuTime;AbsoluteTime schedTime;AbsoluteTime creationTime;ItemCount codePageFaults;ItemCount dataPageFaults;ItemCount preemptions;MPCpuID cpuID;

};typedef struct MPTaskInfoVersion2 MPTaskInfoVersion2;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPTaskStateKind

typedef UInt32 MPTaskStateKind;

AvailabilityAvailable in OS X v10.0 and later.

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

24

Page 25: Apple manual

Declared inMultiprocessing.h

MPTaskWeight

Represents the relative processor weighting of a task.

typedef UInt32 MPTaskWeight;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

MPTimerID

Represents a timer ID.

typedef struct OpaqueMPTimerID * MPTimerID;

DiscussionYou obtain a timer ID by calling the function MPCreateTimer (page 55).

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

TaskStorageIndex

Represents a task storage index value used by functions described in “Accessing Per-Task Storage Variables.”

typedef ItemCount TaskStorageIndex;

AvailabilityAvailable in OS X v10.0 and later.

Multiprocessing Services ReferenceData Types

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

25

Page 26: Apple manual

Declared inMultiprocessing.h

TaskStorageValue

Represents a task storage value used by functions described in “Accessing Per-Task Storage Variables.”

typedef LogicalAddress TaskStorageValue;

AvailabilityAvailable in OS X v10.0 and later.

Declared inMultiprocessing.h

Constants

Allocation constants

The maximum memory allocation size.

enum {kMPMaxAllocSize = 1024L * 1024 * 1024

};

ConstantskMPMaxAllocSize

The maximum allocation size: 1GB.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Task IDs

Use to specify no task ID.

enum {kMPNoID = kInvalidID

};

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

26

Page 27: Apple manual

ConstantskMPNoID

No task ID.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

DiscussionUsed when calling MPTaskIsPreemptive (page 84) if you want to specify the current task.

Data Structure Version Constants

Data structure version information constants.

enum {kMPQueueInfoVersion = 1L | (kOpaqueQueueID << 16),kMPSemaphoreInfoVersion = 1L | (kOpaqueSemaphoreID << 16),kMPEventInfoVersion = 1L | (kOpaqueEventID << 16),kMPCriticalRegionInfoVersion = 1L | (kOpaqueCriticalRegionID << 16),kMPNotificationInfoVersion = 1L | (kOpaqueNotificationID << 16),kMPAddressSpaceInfoVersion = 1L | (kOpaqueAddressSpaceID << 16)

};

ConstantskMPQueueInfoVersion

The MPQueueInfo structure version.

Available in OS X v10.0 and later.

Declared in MultiprocessingInfo.h.

kMPSemaphoreInfoVersionThe MPSemaphoreInfo structure version.

Available in OS X v10.0 and later.

Declared in MultiprocessingInfo.h.

kMPEventInfoVersionThe MPEventInfo structure version.

Available in OS X v10.0 and later.

Declared in MultiprocessingInfo.h.

kMPCriticalRegionInfoVersionThe MPCriticalRegionInfo structure version.

Available in OS X v10.0 and later.

Declared in MultiprocessingInfo.h.

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

27

Page 28: Apple manual

kMPNotificationInfoVersionThe MPNotificationInfo structure version.

Available in OS X v10.0 and later.

Declared in MultiprocessingInfo.h.

kMPAddressSpaceInfoVersionThe MPAddressSpaceInfo structure version.

Available in OS X v10.1 and later.

Declared in MultiprocessingInfo.h.

Values for the MPOpaqueIDClass type

Constants indicating the source of a generic notification.

enum {kOpaqueAnyID = 0,kOpaqueProcessID = 1,kOpaqueTaskID = 2,kOpaqueTimerID = 3,kOpaqueQueueID = 4,kOpaqueSemaphoreID = 5,kOpaqueCriticalRegionID = 6,kOpaqueCpuID = 7,kOpaqueAddressSpaceID = 8,kOpaqueEventID = 9,kOpaqueCoherenceID = 10,kOpaqueAreaID = 11,kOpaqueNotificationID = 12,kOpaqueConsoleID = 13

};

ConstantskOpaqueAnyID

Any source.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kOpaqueProcessIDA process.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

28

Page 29: Apple manual

kOpaqueTaskIDA task.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kOpaqueTimerIDA timer.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kOpaqueQueueIDA queue.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kOpaqueSemaphoreIDA semaphore.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kOpaqueCriticalRegionIDA critical region.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kOpaqueCpuIDA CPU.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kOpaqueAddressSpaceIDAn address space.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kOpaqueEventIDAn event.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kOpaqueCoherenceIDA coherence group.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

29

Page 30: Apple manual

kOpaqueAreaIDAn area.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kOpaqueNotificationIDA notification.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kOpaqueConsoleIDA console.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Memory Allocation Alignment Constants

Specify the alignment of the desired memory block when calling the MPAllocateAligned function.

enum {kMPAllocateDefaultAligned = 0,kMPAllocate8ByteAligned = 3,kMPAllocate16ByteAligned = 4,kMPAllocate32ByteAligned = 5,kMPAllocate1024ByteAligned = 10,kMPAllocate4096ByteAligned = 12,kMPAllocateMaxAlignment = 16,kMPAllocateAltiVecAligned = kMPAllocate16ByteAligned,kMPAllocateVMXAligned = kMPAllocateAltiVecAligned,kMPAllocateVMPageAligned = 254,kMPAllocateInterlockAligned = 255

};

ConstantskMPAllocateDefaultAligned

Use the default alignment.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

30

Page 31: Apple manual

kMPAllocate8ByteAlignedUse 8-byte alignment.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPAllocate16ByteAlignedUse 16-byte alignment.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPAllocate32ByteAlignedUse 32-byte alignment.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPAllocate1024ByteAlignedUse 1024-byte alignment.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPAllocate4096ByteAlignedUse 4096-byte alignment.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPAllocateMaxAlignmentUse the maximum alignment (65536 byte).

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPAllocateAltiVecAlignedUse AltiVec alignment.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPAllocateVMXAlignedUse VMX (now called AltiVec) alignment.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPAllocateVMPageAlignedUse virtual memory page alignment. This alignment is set at runtime.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

31

Page 32: Apple manual

kMPAllocateInterlockAlignedUse interlock alignment, which is the alignment needed to allow the use of CPU interlock instructions(that is, lwarx and stwcx.) on the returned memory address. This alignment is set at runtime. In mostcases you would never need to use this alignment.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Memory Allocation Option Constants

Specify optional actions when calling the MPAllocateAligned function.

enum {kMPAllocateClearMask = 0x0001,kMPAllocateGloballyMask = 0x0002,kMPAllocateResidentMask = 0x0004,kMPAllocateNoGrowthMask = 0x0010,kMPAllocateNoCreateMask = 0x0020

};

ConstantskMPAllocateClearMask

Zero out the allocated memory block.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPAllocateGloballyMaskAllocate memory from in memory space that is visible to all processes. Note that such globally-allocatedspace is not automatically reclaimed when the allocating process terminates. By default,MPAllocateAligned (page 43) allocates memory from process-specific (that is, not global) memory.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPAllocateResidentMaskAllocate memory from resident memory only (that is, the allocated memory is not pageable).

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

32

Page 33: Apple manual

kMPAllocateNoGrowthMaskDo not attempt to grow the pool of available memory. Specifying this option is useful, as attempting togrow memory may cause your task to block until such memory becomes available.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPAllocateNoCreateMaskDo not attempt to create the pool if it does not yet exist.

Available in OS X v10.1 and later.

Declared in Multiprocessing.h.

MPDebuggerLevel

Indicates the debugger level.

typedef UInt32 MPDebuggerLevel;enum {

kMPLowLevelDebugger = 0x00000000,kMPMidLevelDebugger = 0x10000000,kMPHighLevelDebugger = 0x20000000

};

ConstantskMPLowLevelDebugger

The low-level debugger.

Available in OS X v10.1 and later.

Declared in Multiprocessing.h.

kMPMidLevelDebuggerThe mid-level debugger.

Available in OS X v10.1 and later.

Declared in Multiprocessing.h.

kMPHighLevelDebuggerThe high-level debugger.

Available in OS X v10.1 and later.

Declared in Multiprocessing.h.

Library Version Constants

Identifies the current library version.

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

33

Page 34: Apple manual

enum {MPLibrary_MajorVersion = 2,MPLibrary_MinorVersion = 3,MPLibrary_Release = 1,MPLibrary_DevelopmentRevision = 1

};

ConstantsMPLibrary_MajorVersion

Major version number.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

MPLibrary_MinorVersionMinor version number.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

MPLibrary_ReleaseRelease number.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

MPLibrary_DevelopmentRevisionDevelopment revision number.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Remote Call Context Option Constants

Specify which contexts are allowed to execute the callback function when using MPRemoteCall.

enum {kMPAnyRemoteContext = 0,kMPOwningProcessRemoteContext = 1,kMPInterruptRemoteContext = 2,kMPAsyncInterruptRemoteContext = 3

};typedef UInt8 MPRemoteContext;

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

34

Page 35: Apple manual

ConstantskMPAnyRemoteContext

Any cooperative context can execute the function. Note that the called function may not have access toany of the owning context’s process-specific low-memory values.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPOwningProcessRemoteContextOnly the context that owns the task can execute the function.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPInterruptRemoteContextUnsupported in OS X.

Available in OS X v10.1 and later.

Declared in Multiprocessing.h.

kMPAsyncInterruptRemoteContextUnsupported in OS X.

Available in OS X v10.1 and later.

Declared in Multiprocessing.h.

DiscussionThese constants are used to support older versions of Mac OS and are ignored in OS X.

Task Creation Options

Specify optional actions when calling the MPCreateTask function.

enum {kMPCreateTaskSuspendedMask = 1L << 0,kMPCreateTaskTakesAllExceptionsMask = 1L << 1,kMPCreateTaskNotDebuggableMask = 1L << 2,kMPCreateTaskValidOptionsMask = kMPCreateTaskSuspendedMask |

kMPCreateTaskTakesAllExceptionsMask | kMPCreateTaskNotDebuggableMask};typedef OptionBits MPTaskOptions;

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

35

Page 36: Apple manual

ConstantskMPCreateTaskSuspendedMask

Unsupported in OS X.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPCreateTaskTakesAllExceptionsMaskThe task will take all exceptions, including those normally handled by the system, such as page faults.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPCreateTaskNotDebuggableMaskUnsupported in OS X.

Available in OS X v10.1 and later.

Declared in Multiprocessing.h.

kMPCreateTaskValidOptionsMaskInclude all valid options for this task.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Task Exception Disposal Constants

SpecifyactionstotakeonanexceptionwhenpassedintheactionparameteroftheMPDisposeTaskExceptionfunction.

enum {kMPTaskPropagate = 0,kMPTaskResumeStep = 1,kMPTaskResumeBranch = 2,kMPTaskResumeMask = 0x0000,kMPTaskPropagateMask = 1 << kMPTaskPropagate,kMPTaskResumeStepMask = 1 << kMPTaskResumeStep,kMPTaskResumeBranchMask = 1 << kMPTaskResumeBranch

};

ConstantskMPTaskPropagate

The exception is propagated.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

36

Page 37: Apple manual

kMPTaskResumeStepThe task is resumed and single step is enabled.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTaskResumeBranchThe task is resumed and branch stepping is enabled.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTaskResumeMaskResume the task.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTaskPropagateMaskPropagate the exception to the next debugger level.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTaskResumeStepMaskResume the task and enable single stepping.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTaskResumeBranchMaskResume the task and enable branch stepping.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Task Information Structure Version Constant

Indicates the current version of the MPTaskInfo structure (returned as the first field).

enum {kMPTaskInfoVersion = 3

};

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

37

Page 38: Apple manual

ConstantskMPTaskInfoVersion

The current version of the task information structure.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Task Run State Constants

Indicate the state of the task when returned as part of the MPTaskInfo data structure.

enum {kMPTaskBlocked = 0,kMPTaskReady = 1,kMPTaskRunning = 2

};

ConstantskMPTaskBlocked

The task is blocked..

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTaskReadyThe task is ready for execution.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTaskRunningThe task is currently running.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Task State Constants

Specify what states you want to set or obtain when calling the MPExtractTaskState or MPSetTaskStatefunctions.

enum {kMPTaskStateRegisters = 0,kMPTaskStateFPU = 1,

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

38

Page 39: Apple manual

kMPTaskStateVectors = 2,kMPTaskStateMachine = 3,kMPTaskState32BitMemoryException = 4,kMPTaskStateTaskInfo = 5

};

ConstantskMPTaskStateRegisters

The task’s general-purpose (GP) registers. The RegisterInformationPowerPC structure inMachineExceptions.h defines the format of this information.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTaskStateFPUThe task’s floating point registers. The FPUInformationPowerPC structure in MachineExceptions.hdefines the format of this information.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTaskStateVectorsThe task’s vector registers. The VectorInformationPowerPC structure in MachineExceptions.hdefines the format of this information.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTaskStateMachineThe task’s machine registers. The MachineInformationPowerPC structure in MachineExceptions.hdefines the format of this information. Note that the MSR, ExceptKind, DSISR, and DAR registers areread-only.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTaskState32BitMemoryExceptionThe task’s exception information for older 32-bit memory exceptions (that is, memory exceptions on32-bit CPUs). The MemoryExceptionInformation structure in MachineExceptions.h defines theformat of this information. This exception information is read-only.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTaskStateTaskInfoStatic and dynamic information about the task, as described by the data structure MPTaskInfo (page 22).This task information is read-only.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

39

Page 40: Apple manual

Timer Duration Constants

Specify the maximum time a task should wait for an event to occur.

enum {kDurationImmediate = 0,kDurationForever = 0x7FFFFFFF,kDurationMillisecond = 1,kDurationMicrosecond = -1

};

ConstantskDurationImmediate

The task times out immediately, whether or not the event has occurred. If the event occurred, the returnstatus is noErr. If the event did not occur, the return status is kMPTimeoutErr (assuming no other errorsoccurred).

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kDurationForeverThe task waits forever. The blocking call waits until either the event occurs, or until the object beingwaited upon (such as a message queue) is deleted.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kDurationMillisecondThe task waits one millisecond before timing out.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kDurationMicrosecondThe task waits one microsecond before timing out.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

DiscussionYou can use these constants in conjunction with other values to indicate specific wait intervals. For example,to wait 1 second, you can pass kDurationMillisecond * 1000.

Timer Option Masks

Indicate optional actions when calling MPArmTimer.

Multiprocessing Services ReferenceConstants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

40

Page 41: Apple manual

enum {kMPPreserveTimerIDMask = 1L << 0,kMPTimeIsDeltaMask = 1L << 1,kMPTimeIsDurationMask = 1L << 2

};

ConstantskMPPreserveTimerIDMask

Specifying this mask prevents the timer from being deleted when it expires.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTimeIsDeltaMaskSpecifying this mask indicates that the specified time should be added to the previous expiration timeto form the new expiration time. You can use this mask to compensate for timing drift caused by thefinite amount of time required to arm the timer, receive the notification, and so on.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

kMPTimeIsDurationMaskSpecifying this mask indicates that the specified expiration time is of type Duration. You can use thismask to avoid having to call time conversion routines when specifying an expiration time.

Available in OS X v10.0 and later.

Declared in Multiprocessing.h.

Result CodesResult codes defined for Multiprocessing Services are listed below.

DescriptionValueResult Code

Available in OS X v10.0 and later.-29275kMPIterationEndErr

Available in OS X v10.0 and later.-29276kMPPrivilegedErr

Available in OS X v10.0 and later.-29288kMPProcessCreatedErr

Available in OS X v10.0 and later.-29289kMPProcessTerminatedErr

Available in OS X v10.0 and later.-29290kMPTaskCreatedErr

The desired task is blocked.-29291kMPTaskBlockedErr

Available in OS X v10.0 and later.

Multiprocessing Services ReferenceResult Codes

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

41

Page 42: Apple manual

DescriptionValueResult Code

The desired task is stopped.-29292kMPTaskStoppedErr

Available in OS X v10.0 and later.

The desired notification the function was waiting uponwas deleted.

-29295kMPDeletedErr

Available in OS X v10.0 and later.

The designated timeout interval passed before thefunction could take action.

-29296kMPTimeoutErr

Available in OS X v10.0 and later.

Could not complete task due to unavailableMultiprocessing Services resources. Note that manyfunctions return this value as a general error when thedesired action could not be performed.

-29298kMPInsufficientResourcesErr

Available in OS X v10.0 and later.

Invalid ID value. For example, an invalid message queueID was passed to MPNotifyQueue.

-29299kMPInvalidIDErr

Available in OS X v10.0 and later.

Gestalt ConstantsYou can determine which system software calls are preemptively-safe for Multiprocessing Services by usingthe preemptive function attribute selectors defined in the Gestalt Manager. For more information, see GestaltManager Reference .

Multiprocessing Services ReferenceGestalt Constants

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

42

Page 43: Apple manual

A function identified as deprecated has been superseded and may become unsupported in the future.

Deprecated in OS X v10.7

MPAllocate

Allocates a nonrelocatable memory block. (Deprecated in OS X v10.7. Use MPAllocateAligned instead.)

LogicalAddress MPAllocate (ByteCount size

);

Parameterssize

The size, in bytes, of the memory block to allocate.

Return ValueA pointer to the allocated memory. If the function cannot allocate the requested memory or the requestedalignment, the returned address is NULL.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPAllocateAligned

Allocates a nonrelocatable memory block. (Deprecated in OS X v10.7.)

LogicalAddress MPAllocateAligned (

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

43

Deprecated Multiprocessing Services Functions

Page 44: Apple manual

ByteCount size,UInt8 alignment,OptionBits options

);

Parameterssize

The size, in bytes, of the memory block to allocate.

alignmentThe desired alignment of the allocated memory block. See “Memory Allocation Alignment Constants” (page30) for a list of possible values to pass. Note that there will be a minimum alignment regardless of therequested alignment. If the requested memory block is 4 bytes or smaller, the block will be at least 4-bytealigned. If the requested block is greater than 4 bytes, the block will be at least 8-byte aligned.

optionsAny optional information to use with this call. See “Memory Allocation Option Constants” (page 32) fora list of possible values to pass.

Return ValueA pointer to the allocated memory. If the function cannot allocate the requested memory or the requestedalignment, the returned address is NULL.

DiscussionThe memory referenced by the returned address is guaranteed to be accessible by the application's cooperativetask and any preemptive tasks that it creates, but not by other applications or their preemptive tasks. Anyexisting non-global heap blocks are freed when the application terminates. As with all shared memory, youmust explicitly synchronize access to allocated heap blocks using a notification mechanism.

You can replicate the effect of the older MPAllocate function by calling MPAllocateAligned with 32-bytealignment and no options.

Also see the function MPFree (page 67).

Special ConsiderationsOS X does not support allocation of global (cross address space) or resident memory with this function. Inaddition, passing the kMPAllocateNoGrowthMask constant in the options parameter has no effect in OSX, since memory allocation is done with sparse heaps.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

44

Page 45: Apple manual

Declared inMultiprocessing.h

MPAllocateTaskStorageIndex

Returns an index number to access per-task storage. (Deprecated in OS X v10.7.)

OSStatus MPAllocateTaskStorageIndex (TaskStorageIndex *taskIndex

);

Parametersindex

On return, index contains an index number you can use to store task data.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionA call to the function MPAllocateTaskStorageIndex returns an index number that is common across alltasks in the current process. You can use this index number in calls to MPSetTaskStorageValue (page 81) andMPGetTaskStorageValue (page 69) to set a different value for each task using the same index.

You can think of the task storage area as a two dimensional array cross-referenced by the task storage indexnumber and the task ID. Note that since the amount of per-task storage is determined when the task is created,the number of possible index values associated with a task is limited.

Also see the function MPDeallocateTaskStorageIndex (page 57).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPArmTimer

Arms the timer to expire at a given time. (Deprecated in OS X v10.7.)

OSStatus MPArmTimer (

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

45

Page 46: Apple manual

MPTimerID timerID,AbsoluteTime *expirationTime,OptionBits options

);

ParameterstimerID

The ID of the timer you want to arm.

expirationTimeA pointer to a value that specifies when you want the timer to expire. Note that if you arm the timer witha time that has already passed, the timer expires immediately.

optionsAny optional actions. See “Timer Option Masks” (page 40) for a list of possible values.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41). If the timer has already expired, the resetdoes not take place and the function returns kMPInsufficientResourcesErr.

DiscussionThe expiration time is an absolute time, which you can generate by calling the Driver Services Library functionUpTime. When the timer expires, a notification is sent to the notification mechanism specified in the lastMPSetTimerNotify (page 82) call. If the specified notification ID has become invalid, no action is taken whenthe timer expires. The timer itself is deleted when it expires unless you specified the kMPPreserveTimerIDoption in the options parameter.

Also see the function MPCancelTimer (page 48).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPBlockClear

Clears a block of memory. (Deprecated in OS X v10.7.)

void MPBlockClear (LogicalAddress address,

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

46

Page 47: Apple manual

ByteCount size);

Parametersaddress

The starting address of the memory block you want to clear.

sizeThe number of bytes you want to clear.

DiscussionAs with all shared memory, your application must synchronize access to the memory blocks to avoid datacorruption. MPBlockClear ensures the clearing stays within the bounds of the area specified by size, butthe calling task can be preempted during the copying process.

Note that you can call this function from an interrupt handler.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPBlockCopy

Copies a block of memory. (Deprecated in OS X v10.7.)

void MPBlockCopy (LogicalAddress source,LogicalAddress destination,ByteCount size

);

Parameterssource

The starting address of the memory block you want to copy.

destinationThe location to which you want to copy the memory block.

sizeThe number of bytes to copy.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

47

Page 48: Apple manual

DiscussionThis function simply calls through to the Driver Services Library function BlockMoveData. Note that youshould not make any assumptions about the state of the destination memory while this function is executing.In the intermediate state, values may be present that are neither the original nor the final ones. For example,this function may use the 'dcbz' instruction. If the underlying memory is not cacheable, if the memory iswrite-through instead of copy-back, or if the cache block is flushed for some reason, the 'dcbz' instructionwill write zeros to the destination. You can avoid the use of the 'dcbz' instruction by callingBlockMoveDataUncached, but even that function makes no other guarantees about the memory block'sintermediate state.

As with all shared memory, your application must synchronize access to the memory blocks to avoid datacorruption. MPBlockCopy ensures the copying stays within the bounds of the area specified by size, but thecalling task can be preempted during the copying process.

Note that you can call this function from an interrupt handler.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPCancelTimer

Cancels an armed timer. (Deprecated in OS X v10.7.)

OSStatus MPCancelTimer (MPTimerID timerID,AbsoluteTime *timeRemaining

);

ParameterstimerID

The ID of the armed timer you want to cancel.

timeRemainingOn return, the timeRemaining contains the time remaining before the timer would have expired.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

48

Page 49: Apple manual

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41). If the timer has already expired, thisfunction returns kMPInsufficientResourcesErr.

DiscussionAlso see the function MPArmTimer (page 45).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPCauseNotification

Signals a kernel notification. (Deprecated in OS X v10.7.)

OSStatus MPCauseNotification (MPNotificationID notificationID

);

ParametersnotificationID

The ID of the kernel notification you want to signal.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionYou call this function to signal a kernel notification much as you would signal any simple notification (forexample, MPNotifyQueue (page 72) ).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

49

Page 50: Apple manual

MPCreateCriticalRegion

Creates a critical region object. (Deprecated in OS X v10.7.)

OSStatus MPCreateCriticalRegion (MPCriticalRegionID *criticalRegion

);

ParameterscriticalRegion

On return, the criticalRegion contains the ID of the newly created critical region object.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionAlso see the function MPDeleteCriticalRegion (page 59).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPCreateEvent

Creates an event group. (Deprecated in OS X v10.7.)

OSStatus MPCreateEvent (MPEventID *event

);

Parametersevent

On return, event contains the ID of the newly created event group.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

50

Page 51: Apple manual

DiscussionEvent groups are created from dynamically allocated internal resources. Other tasks may be competing forthese resources so it is possible that this function will not be able to create an event group.

Also see the function MPDeleteEvent (page 59).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPCreateNotification

Creates a kernel notification (Deprecated in OS X v10.7.)

OSStatus MPCreateNotification (MPNotificationID *notificationID

);

ParametersnotificationID

On return, notificationID points to the newly created kernel notification.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionAfter creating the kernel notification object, you can add simple notifications by calling the functionMPModifyNotification (page 70).

Also see the function MPDeleteNotification (page 60).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

51

Page 52: Apple manual

MPCreateQueue

Creates a message queue. (Deprecated in OS X v10.7.)

OSStatus MPCreateQueue (MPQueueID *queue

);

Parametersqueue

On return, the variable contains the ID of the newly created message queue.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41). If a queue could not be created,MPCreateQueue returns kMPInsufficientResourcesErr.

DiscussionThis call creates a message queue, which can be used to notify (that is, send) and wait for (that is, receive)messages consisting of three pointer-sized values in a preemptively safe manner.

Message queues are created from dynamically allocated internal resources. Other tasks may be competing forthese resources so it is possible this function may not be able to create a queue.

See also the functions MPDeleteQueue (page 61) and MPSetQueueReserve (page 78).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPCreateSemaphore

Creates a semaphore. (Deprecated in OS X v10.7.)

OSStatus MPCreateSemaphore (MPSemaphoreCount maximumValue,MPSemaphoreCount initialValue,MPSemaphoreID *semaphore

);

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

52

Page 53: Apple manual

ParametersmaximumValue

The maximum allowed value of the semaphore.

initialValueThe initial value of the semaphore.

semaphoreOn return, semaphore contains the ID of the newly–created semaphore.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionIf you want to create a binary semaphore, you can call the macro MPCreateBinarySemaphore(MPSemaphoreID *semaphore) instead, which simply calls MPCreateSemaphorewith both maximumValueand initialValue set to 1.

Also see the function MPDeleteSemaphore (page 61).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPCreateTask

Creates a preemptive task. (Deprecated in OS X v10.7.)

OSStatus MPCreateTask (TaskProc entryPoint,void *parameter,ByteCount stackSize,MPQueueID notifyQueue,void *terminationParameter1,void *terminationParameter2,MPTaskOptions options,MPTaskID *task

);

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

53

Page 54: Apple manual

ParametersentryPoint

A pointer to the task function. The task function should take a single pointer-sized parameter and returna value of type OSStatus.

parameterThe parameter to pass to the task function.

stackSizeThe size of the stack assigned to the task. Note that you should be careful not to exceed the bounds ofthe stack, since stack overflows may not be detected. Specifying zero for the size will result in a defaultstack size of 4KB.

Note that in OS X prior to version 10.1, this parameter is ignored, and all stacks have the default size of512 KB. Versions 10.1 and later do not have this limitation.

notifyQueueThe ID of the message queue to which the system will send a message when the task terminates. Youspecify the first two values of the message in the parameters terminationParameter1 andterminationParameter2 respectively. The last message value contains the result code of the taskfunction.

terminationParameter1A pointer-sized value that is sent to the message queue specified by the parameter notifyQueue whenthe task terminates.

terminationParameter2A pointer-sized value that is sent to the message queue specified by the parameter notifyQueue whenthe task terminates.

optionsOptional attributes of the preemptive task. See “Task Creation Options” (page 35) for a list of possiblevalues.

taskOn return, task points to the ID of the newly created task.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41). If MPCreateTask could not create thetask because some critical resource was not available, the function returns kMPInsufficientResourcesErr.Usually this is due to lack of memory to allocate the internal data structures associated with the task or thestack. The function also returns kMPInsufficientResourcesErr if any reserved option bits are set.

DiscussionTasks are created in the unblocked state, ready for execution. A task can terminate in the following ways:

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

54

Page 55: Apple manual

● By returning from its entry point

● By calling MPExit (page 64)

● When specified as the target of an MPTerminateTask (page 85) call

● If a hardware-detected exception or programming exception occurs and no exception handler is installed

● If the application calls ExitToShell

Task resources (its stack, active timers, internal structures related to the task, and so on) are reclaimed by thesystem when the task terminates. The task's address space is inherited from the process address space. Allexisting tasks are terminated when the owning process terminates.

To set the relative processor weight to be assigned to a task, use the function MPSetTaskWeight (page 81).

See also the function MPTerminateTask (page 85).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPCreateTimer

Creates a timer. (Deprecated in OS X v10.7.)

OSStatus MPCreateTimer (MPTimerID *timerID

);

ParameterstimerID

On return, the timerID contains the ID of the newly created timer.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionYou can use a timer to notify an event, queue, or semaphore after a specified amount of time has elapsed.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

55

Page 56: Apple manual

Timer objects are created from dynamically-allocated internal resources. Other tasks may be competing forthese resources so it is possible this function may not be able to create one.

To specify the notification mechanism to signal, use the function MPSetTimerNotify (page 82).

Also see the functions MPDeleteTimer (page 62) and MPArmTimer (page 45).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPCurrentTaskID

Obtains the task ID of the currently-executing preemptive task (Deprecated in OS X v10.7.)

MPTaskID MPCurrentTaskID (void

);

Return ValueThe task ID of the current preemptive task. See the description of the MPTaskID data type.

DiscussionReturns the ID of the current preemptive task. If called from a cooperative task, this function returns an IDwhich is different than the ID of any preemptive task. Nonpreemptive processes may or may not have differenttask IDs for each application; future implementations of this API may behave differently in this regard.

Note that you can call this function from an interrupt handler.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

56

Page 57: Apple manual

MPDataToCode

Designates the specified block of memory as executable code. (Deprecated in OS X v10.7.)

void MPDataToCode (LogicalAddress address,ByteCount size

);

Parametersaddress

The starting address of the memory block you want to designate as code.

sizeThe size of the memory block.

DiscussionSince processors need to differentiate between code and data in memory, you should call this function to tagany executable code that your tasks may generate.

Note that you can call this function from an interrupt handler.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Not available to 64-bit applications.

Declared inMultiprocessing.h

MPDeallocateTaskStorageIndex

Frees an index number used to access per-task storage (Deprecated in OS X v10.7.)

OSStatus MPDeallocateTaskStorageIndex (TaskStorageIndex taskIndex

);

Parametersindex

The index number you want to deallocate.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

57

Page 58: Apple manual

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionAlso see the function MPAllocateTaskStorageIndex (page 45).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPDelayUntil

Blocks the calling task until a specified time. (Deprecated in OS X v10.7.)

OSStatus MPDelayUntil (AbsoluteTime *expirationTime

);

ParametersexpirationTime

The time to unblock the task.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionYou cannot call this function from a cooperative task.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

58

Page 59: Apple manual

MPDeleteCriticalRegion

Removes the specified critical region object. (Deprecated in OS X v10.7.)

OSStatus MPDeleteCriticalRegion (MPCriticalRegionID criticalRegion

);

ParameterscriticalRegion

The critical region object you want to remove.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionCalling this function unblocks all tasks waiting to enter the critical region and their respectiveMPEnterCriticalRegion (page 63) calls will return with the result code kMPDeletedErr.

Also see the function MPCreateCriticalRegion (page 50).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPDeleteEvent

Removes an event group. (Deprecated in OS X v10.7.)

OSStatus MPDeleteEvent (MPEventID event

);

Parametersevent

The ID of the event group you want to remove.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

59

Page 60: Apple manual

DiscussionAfter deletion, the event ID becomes invalid, and all internal resources associated with the event group arereclaimed. Calling this function unblocks all tasks waiting on the event group and their respectiveMPWaitForEvent (page 88) calls will return with the result code kMPDeletedErr.

Also see the function MPCreateEvent (page 50).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPDeleteNotification

Removes a kernel notification. (Deprecated in OS X v10.7.)

OSStatus MPDeleteNotification (MPNotificationID notificationID

);

ParametersnotificationID

The ID of the notification you want to remove.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionAlso see the function MPCreateNotification (page 51).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

60

Page 61: Apple manual

MPDeleteQueue

Deletes a message queue. (Deprecated in OS X v10.7.)

OSStatus MPDeleteQueue (MPQueueID queue

);

Parametersqueue

The ID of the message queue you want to delete.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionAfter calling MPDeleteQueue, the specified queue ID becomes invalid, and all internal resources associatedwith the queue (including queued messages) are reclaimed. Any tasks waiting on the queue are unblockedand their respective MPWaitOnQueue (page 89) calls will return with the result code kMPDeletedErr.

Also see the function MPCreateQueue (page 52).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPDeleteSemaphore

Removes a semaphore. (Deprecated in OS X v10.7.)

OSStatus MPDeleteSemaphore (MPSemaphoreID semaphore

);

Parameterssemaphore

The ID of the semaphore you want to remove.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

61

Page 62: Apple manual

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionCalling this function unblocks all tasks waiting on the semaphore and the tasks’ respectiveMPWaitOnSemaphore (page 91) calls will return with the result code kMPDeletedErr.

Also see the function MPCreateSemaphore (page 52).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPDeleteTimer

Removes a timer. (Deprecated in OS X v10.7.)

OSStatus MPDeleteTimer (MPTimerID timerID

);

ParameterstimerID

The ID of the timer you want to remove.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionAfter deletion, the timer ID becomes invalid, and all internal resources associated with the timer are reclaimed.

Also see the function MPCreateTimer (page 55).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

62

Page 63: Apple manual

Declared inMultiprocessing.h

MPDisposeTaskException

Removes a task exception. (Deprecated in OS X v10.7.)

OSStatus MPDisposeTaskException (MPTaskID task,OptionBits action

);

Parameterstask

The task whose exception you want to remove.

actionAny actions to perform on the task. For example, you can enable single-stepping when the task resumes,or you can pass the exception on to another handler. See “Task Exception Disposal Constants” (page 36)for a listing of possible values.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41). If the specified action is invalid orunsupported, or if the specified task is not suspended, this function returns kMPInsufficientResourcesErr.

DiscussionThis function removes the task exception and allows the task to resume operation. If desired, you can enablesingle-stepping or branch-stepping, or propagate the exception instead.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPEnterCriticalRegion

Attempts to enter a critical region. (Deprecated in OS X v10.7.)

OSStatus MPEnterCriticalRegion (

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

63

Page 64: Apple manual

MPCriticalRegionID criticalRegion,Duration timeout

);

ParameterscriticalRegion

The ID of the critical region you want to enter.

timeoutThe maximum time to wait for entry before timing out. See “Timer Duration Constants” (page 40) for alist of constants you can use to specify the wait interval.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionIf another task currently occupies the critical region, the current task is blocked until the critical region isreleased or until the designated timeout expires. Otherwise the task enters the critical region andMPEnterCriticalRegion increments the region’s use count.

Once a task enters a critical region it can make further calls to MPEnterCriticalRegion without blocking(its use count increments for each call). However, each call to MPEnterCriticalRegion must be balancedby a call to MPExitCriticalRegion (page 65) ; otherwise the region is not released for use by other tasks.

Note that you can enter a critical region from a cooperative task. Each cooperative task is treated as uniqueand different from any preemptive task. If you call this function from a cooperative task, you should specifyonly kDurationImmediate for the timeout length; other waits will cause the task to block.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPExit

Allows a task to terminate itself (Deprecated in OS X v10.7.)

void MPExit (OSStatus status

);

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

64

Page 65: Apple manual

Parametersstatus

An application-defined value that indicates termination status. This value is sent to the terminationmessage queue in place of the task’s result code.

DiscussionWhen called from within a preemptive task, the task terminates, and the value indicated by the parameterstatus is sent to the termination message queue you specified in MPCreateTask (page 53). Note that youcannot call MPExit from outside a preemptive task.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPExitCriticalRegion

Exits a critical region. (Deprecated in OS X v10.7.)

OSStatus MPExitCriticalRegion (MPCriticalRegionID criticalRegion

);

ParameterscriticalRegion

The ID of the critical region you want to exit.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41). If the task does not own the criticalregion specified by criticalRegion, MPExitCriticalRegion returns kMPInsufficientResourcesErr.

DiscussionThis function decrements the use count of the critical region object. When the use count reaches zero, ownershipof the critical region object is released (which allows another task to use the critical region).

Also see the function MPEnterCriticalRegion (page 63).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

65

Page 66: Apple manual

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPExtractTaskState

Extracts state information from a suspended task. (Deprecated in OS X v10.7.)

OSStatus MPExtractTaskState (MPTaskID task,MPTaskStateKind kind,void *info

);

Parameterstask

The task whose state information you want to obtain.

kindThe kind of state information you want to obtain. See “Task State Constants” (page 38) for a listing ofpossible values.

infoA pointer to a data structure to hold the state information. On return, the data structure holds the desiredstate information. The format of the data structure varies depending on the state information you wantto retrieve. See the header file MachineExceptions.h for the formats of the various state informationstructures.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41). If you attempt to extract state informationfor a running task, this function returns kMPInsufficientResourcesErr.

DiscussionYou can use this function to obtain register contents or exception information about a particular task.

Also see the function MPSetTaskState (page 79).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

66

Page 67: Apple manual

Declared inMultiprocessing.h

MPFree

Frees memory allocated by MPAllocateAligned. (Deprecated in OS X v10.7.)

void MPFree (LogicalAddress object

);

Parametersobject

A pointer to the memory you want to release.

DiscussionAlso see the function MPAllocateAligned (page 43).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPGetAllocatedBlockSize

Returns the size of a memory block. (Deprecated in OS X v10.7.)

ByteCount MPGetAllocatedBlockSize (LogicalAddress object

);

Parametersobject

The address of the memory block whose size you want to determine.

Return ValueThe size of the allocated memory block, in bytes.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

67

Page 68: Apple manual

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPGetNextCpuID

Obtains the next CPU ID in the list of physical processors of the specified memory coherence group. (Deprecatedin OS X v10.7.)

OSStatus MPGetNextCpuID (MPCoherenceID owningCoherenceID,MPCpuID *cpuID

);

ParametersowningCoherenceID

The ID of the memory coherence group whose physical processor IDs you want to obtain. PasskMPInvalidIDErr, as only one coherence group, internal RAM, is currently defined.

cpuIDOn return, cpuID points to the ID of the next physical processor.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionBy iterating on this function (after calling MPProcessors (page 73) , for example), you can obtain the IDs of allthe processors available on the host computer. Generally, you would only use this function in diagnosticprograms.

AvailabilityAvailable in OS X v10.4 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessingInfo.h

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

68

Page 69: Apple manual

MPGetNextTaskID

Obtains the next task ID in the list of available tasks. (Deprecated in OS X v10.7.)

OSStatus MPGetNextTaskID (MPProcessID owningProcessID,MPTaskID *taskID

);

ParametersowningProcessID

The ID of the process (typically the application) that owns the tasks. This ID is the same as the process IDhandled by the Code Fragment Manager.

taskIDOn return, taskID points to ID of the next task in the list of tasks.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionBy iterating on this function, you can obtain the IDs of all the tasks in a given process. These tasks may berunning, ready, or blocked. Generally you would only use this function in diagnostic programs.

AvailabilityAvailable in OS X v10.4 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessingInfo.h

MPGetTaskStorageValue

Gets the storage value stored at a specified index number. (Deprecated in OS X v10.7.)

TaskStorageValue MPGetTaskStorageValue (TaskStorageIndex taskIndex

);

Parametersindex

The index number of the storage value you want to obtain.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

69

Page 70: Apple manual

Return ValueThe value stored at the specified index number. See the description of the TaskStorageValue data type.

DiscussionCalling this function from within a task effectively reads a value in a two-dimensional array cross-referencedby task storage index value and the task ID.

Note that since this function does not return any status information, it may not be immediately obvious whetherthe returned storage value is valid.

Also see the function MPSetTaskStorageValue (page 81).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPModifyNotification

Adds a simple notification to a kernel notification. (Deprecated in OS X v10.7.)

OSStatus MPModifyNotification (MPNotificationID notificationID,MPOpaqueID anID,void *notifyParam1,void *notifyParam2,void *notifyParam3

);

ParametersnotificationID

The ID of the kernel notification you want to add to..

anIDThe ID of the simple notification (semaphore, message group, or event group) you want to add to thekernel notification.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

70

Page 71: Apple manual

notifyParam1If anID specifies an event group, this parameter should contain the flags to set in the event group whenMPCauseNotification (page 49) is called. If anID specifies a message queue, this parameter shouldcontain the first pointer-sized value of the message to be sent to the message queue whenMPCauseNotification (page 49) is called.

notifyParam2If anID specifies a message queue, this parameter should contain the second pointer-sized value of themessage to be sent to the message queue when MPCauseNotification (page 49) is called. Pass NULL ifyou don’t need this parameter.

notifyParam3If anID specifies a message queue, this parameter should contain the third pointer-sized value of themessage sent to the message queue when MPCauseNotification (page 49) is called. Pass NULL if youdon’t need this parameter.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionYou specify the parameters for the simple notifications just as if you were calling the MPSetTimerNotify (page

82) function.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPModifyNotificationParameters

(Deprecated in OS X v10.7.)

OSStatus MPModifyNotificationParameters (MPNotificationID notificationID,MPOpaqueIDClass kind,void *notifyParam1,void *notifyParam2,void *notifyParam3

);

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

71

Page 72: Apple manual

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

AvailabilityAvailable in OS X v10.1 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPNotifyQueue

Sends a message to the specified message queue. (Deprecated in OS X v10.7.)

OSStatus MPNotifyQueue (MPQueueID queue,void *param1,void *param2,void *param3

);

Parametersqueue

The queue ID of the message queue you want to notify.

param1The first pointer-sized value of the message to send.

param2The second pointer-sized value of the message to send.

param3The third pointer-sized value of the message to send.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionThis function sends a message to the specified queue, which consist of the three parameters, param1, param2,and param3. The system does not interpret the three values which comprise the text of the message. If tasksare waiting on the specified queue, the first waiting task is unblocked and the task’s MPWaitOnQueue (page 89)

function completes.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

72

Page 73: Apple manual

Depending on the queue mode, the system either allocates messages dynamically or assigns them to memoryreserved for the queue. In either case, if no more memory is available for messages MPNotifyQueue returnskMPInsufficientResourcesErr.

You can call this function from an interrupt handler if messages are reserved on the queue. For more informationabout queueing modes and reserving messages, see MPSetQueueReserve (page 78).

Also see the function MPWaitOnQueue (page 89).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPProcessors

Returns the number of processors on the host computer. (Deprecated in OS X v10.7.)

ItemCount MPProcessors (void

);

Return ValueThe number of physical processors on the host computer.

DiscussionSee also the function MPProcessorsScheduled (page 73).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPProcessorsScheduled

Returns the number of active processors available on the host computer. (Deprecated in OS X v10.7.)

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

73

Page 74: Apple manual

ItemCount MPProcessorsScheduled (void

);

Return ValueThe number of active processors available on the host computer.

DiscussionThe number of active processors is defined as the number of processors scheduled to run tasks. This numbervaries while the system is running. Advanced power management facilities may stop or start schedulingprocessors in the system to control power consumption or to maintain a proper operating temperature.

See also the function MPProcessors (page 73).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPRegisterDebugger

Registers a debugger. (Deprecated in OS X v10.7.)

OSStatus MPRegisterDebugger (MPQueueID queue,MPDebuggerLevel level

);

Parametersqueue

The ID of the queue to which you want exception messages and other information to be sent.

levelThe level of this debugger with respect to other debuggers. Exceptions and informational messages aresent first to the debugger with the highest level. If more than one debugger attempts to register at aparticular level, only the first debugger is registered. Other attempts return an error.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

74

Page 75: Apple manual

DiscussionIn OS X, this function is available but is not implemented. Use system debugging services to write a debuggerfor OS X.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPRemoteCall

Calls a non-reentrant function and blocks the current task. (Deprecated in OS X v10.7.)

void * MPRemoteCall (MPRemoteProcedure remoteProc,void *parameter,MPRemoteContext context

);

ParametersremoteProc

A pointer to the application-defined function you want to call. See MPRemoteProcedure (page 12) formore information about the form of this function.

parameterA pointer to a parameter to pass to the application-defined function. For example, this value could pointto a data structure or a memory location.

contextThis parameter is ignored; specify kMPOwningProcessRemoteContext.

Return ValueThe value that your remote procedure callback returned.

DiscussionYou use this function to execute code on your application’s main task. The remoteProc function is scheduledon the application’s main run loop and run in the default mode (kCFRunloopDefaultMode). If you call thisfunction from your application’s main task, the remoteProc function is executed immediately in the currentmode without blocking the task; otherwise, calling this function blocks the current task until the remote callcompletes.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

75

Page 76: Apple manual

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPRemoteCallCFM

Calls a non-reentrant function and blocks the current task. (Deprecated in OS X v10.7.)

void * MPRemoteCallCFM (MPRemoteProcedure remoteProc,void *parameter,MPRemoteContext context

);

ParametersremoteProc

A pointer to the application-defined CFM (Code Fragment Manager) function you want to call. SeeMPRemoteProcedure (page 12) for more information about the form of this function.

parameterA pointer to a parameter to pass to the application-defined function. For example, this value could pointto a data structure or a memory location.

contextThis parameter is ignored; specify kMPOwningProcessRemoteContext.

Return ValueThe value that your remote procedure callback returned.

DiscussionYou use this function to execute code on your application’s main task. The remoteProc function is scheduledon the application’s main run loop and run in the default mode (kCFRunloopDefaultMode). If you call thisfunction from your application’s main task, the remoteProc function is executed immediately in the currentmode without blocking the task; otherwise, calling this function blocks the current task until the remote callcompletes.

AvailabilityAvailable in OS X v10.4 and later.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

76

Page 77: Apple manual

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPSetEvent

Merges event flags into a specified event group. (Deprecated in OS X v10.7.)

OSStatus MPSetEvent (MPEventID event,MPEventFlags flags

);

Parametersevent

The ID of the event group you want to set.

flagsThe flags you want to merge into the event group.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionThe flags are logically ORed with the current flags in the event group. This procedure is an atomic operationto ensure that multiple updates do not get lost. If tasks are waiting on this event group, the first waiting taskis unblocked.

Note that you can call this function from an interrupt handler.

Also see the function MPWaitForEvent (page 88).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

77

Page 78: Apple manual

MPSetExceptionHandler

Sets an exception handler for a task. (Deprecated in OS X v10.7.)

OSStatus MPSetExceptionHandler (MPTaskID task,MPQueueID exceptionQ

);

Parameterstask

The task to associate with the exception handler.

exceptionQThe message queue to which an exception message will be sent.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionWhen an exception handler is set and an exception occurs, the task is suspended and a message is sent to themessage queue specified by exceptionQ. The message contains the following information:

● The first pointer-sized value contains the ID of the task in which the exception occurred.

● The second pointer-sized value contains the type of exception that occurred. See the header fileMachineExceptions.h for a listing of exception types.

● The last pointer-sized value is set to NULL (reserved for future use).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPSetQueueReserve

Reserves space for messages on a specified message queue. (Deprecated in OS X v10.7.)

OSStatus MPSetQueueReserve (MPQueueID queue,

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

78

Page 79: Apple manual

ItemCount count);

Parametersqueue

The ID of the queue whose messages you want to reserve.

countThe number of messages to reserve.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionMPNotifyQueue (page 72) allocates spaces for messages dynamically; that is, memory to hold the message isallocated for the queue at the time of the call. In most cases this method is both speed and storage efficient.However, it is possible that, due to lack of memory resources, space for the message may not be available atthe time of the call; in such cases, MPNotifyQueue (page 72) will return kInsufficientResourcesErr.

If you must have guaranteed message delivery, or if you need to call MPNotifyQueue (page 72) from an interrupthandler, you should reserve space on the specified queue by calling MPSetQueueReserve. Because suchallocated space is reserved for duration of the queue’s existence, you should avoid straining internal systemresources by reserving messages only when absolutely necessary. Note that if you have reserved messages ona queue, additional space cannot be added dynamically if the number of messages exceeds the numberreserved for that queue.

The number of reserved messages is set to count, lowering or increasing the current number of reservedmessages as required. If count is set to zero, no messages are reserved for the queue, and space for messagesis allocated dynamically.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPSetTaskState

Sets state information for a suspended task. (Deprecated in OS X v10.7.)

OSStatus MPSetTaskState (

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

79

Page 80: Apple manual

MPTaskID task,MPTaskStateKind kind,void *info

);

Parameterstask

The task whose state information you want to set.

kindThe kind of state information you want to set. See “Task State Constants” (page 38) for a listing of possiblevalues. Note that some state information is read-only and cannot be changed using this function.

infoA pointer to a data structure holding the state information you want to set. The format of the datastructure varies depending on the state information you want to set. See the header fileMachineExceptions.h for the formats of the various state information structures.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41). If you specifykMPTaskState32BitMemoryException for the state information, this function returnskMPInsufficientResourcesErr, since the exception state information is read-only. Attempting to set stateinformation for a running task will also return kMPInsufficientResourcesErr.

DiscussionYou can use this function to set register contents or exception information for a particular task. However, somestate information, such as the exception information (as specified by kMPTaskState32BitMemoryException)as well as the MSR, ExceptKind, DSISR, and DARmachine registers (specified under kMPTaskStateMachine)are read-only. Attempting to set the read-only machine registers will do nothing, while attempting to set theexception information will return an error.

Also see the function MPExtractTaskState (page 66).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

80

Page 81: Apple manual

MPSetTaskStorageValue

Sets the storage value for a given index number. (Deprecated in OS X v10.7.)

OSStatus MPSetTaskStorageValue (TaskStorageIndex taskIndex,TaskStorageValue value

);

Parametersindex

The index number whose storage value you want to set.

valueThe value you want to set.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionTypically you use MPSetTaskStorageValue to store pointers to task-specific structures or data.

Calling this function from within a task effectively assigns a value in a two-dimensional array cross-referencedby task storage index value and the task ID.

Also see the function MPGetTaskStorageValue (page 69).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPSetTaskWeight

Assigns a relative weight to a task, indicating how much processor time it should receive compared to otheravailable tasks. (Deprecated in OS X v10.7.)

OSStatus MPSetTaskWeight (MPTaskID task,MPTaskWeight weight

);

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

81

Page 82: Apple manual

Parameterstask

The ID of the task to which you want to assign a weighting.

weightThe relative weight to assign. This value can range from 1 to 10,000, with the default value being 100.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionThe approximate processor share is defined as:

weight of the task / total weight of available tasks

For a set of ready tasks, the amount of CPU time dedicated to the tasks will be determined by the dynamicallycomputed share. Note that the processor share devoted to tasks may deviate from the suggested weightingif critical tasks require attention. For example, a real-time task (such as a QuickTime movie) may require morethan its relative weight of processor time, and the scheduler will adjust proportions accordingly.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPSetTimerNotify

Sets the notification information associated with a timer. (Deprecated in OS X v10.7.)

OSStatus MPSetTimerNotify (MPTimerID timerID,MPOpaqueID anID,void *notifyParam1,void *notifyParam2,void *notifyParam3

);

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

82

Page 83: Apple manual

ParameterstimerID

The ID of the timer whose notification information you want to set.

notificationIDThe ID of the notification mechanism to associate with the timer. This value should be the ID of an eventgroup, a message queue, or a semaphore.

notifyParam1If anID specifies an event group, this parameter should contain the flags to set in the event group whenthe timer expires. If anID specifies a message queue, this parameter should contain the first pointer-sizedvalue of the message to be sent to the message queue when the timer expires.

notifyParam2If anID specifies a message queue, this parameter should contain the second pointer-sized value of themessage to be sent to the message queue when the timer expires. Pass NULL if you don’t need thisparameter.

notifyParam3If anID specifies a message queue, this parameter should contain the third pointer-sized value of themessage sent to the message queue when the timer expires. Pass NULL if you don’t need this parameter.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionWhen the timer expires, Multiprocessing Services checks the notification ID, and if it is valid, notifies the relatednotification mechanisms (that is, event groups, queues, or semaphores) you had specified in yourMPSetTimerNotify (page 82) calls.

You can specify multiple notification mechanisms by calling this function several times. For example, you cancall MPSetTimerNotify to specify a message queue and then call it again to specify a semaphore. When thetimer expires, a message is sent to the message queue and the appropriate semaphore is signaled. You cannot,however, specify more than one notification per notification mechanism (for example, if you callMPSetTimerNotify twice, specifying different messages or message queues in each call, the second call willoverwrite the first). Note that if a call to MPSetTimerNotify returns an error, any previous calls specifyingthe same timer are still valid; previously set notifications will still be notified when the timer expires.

You can set the notification information at any time. If the timer is armed, it will modify the notificationparameters dynamically. If the timer is disarmed, it will modify the notification parameters to be used for thenext MPArmTimer (page 45) call.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

83

Page 84: Apple manual

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPSignalSemaphore

Signals a semaphore. (Deprecated in OS X v10.7.)

OSStatus MPSignalSemaphore (MPSemaphoreID semaphore

);

Parameterssemaphore

The ID of the semaphore you want to signal.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41). If the value of the semaphore was alreadyat the maximum, MPSignalSemaphore returns kInsufficientResourcesErr.

DiscussionIf tasks are waiting on the semaphore, the oldest (first queued) task is unblocked so that the correspondingMPWaitOnSemaphore (page 91) call for that task completes. Otherwise, if the value of the semaphore is notalready equal to its maximum value, it is incremented by one.

Note that you can call this function from an interrupt handler.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPTaskIsPreemptive

Determines whether a task is preemptively scheduled. (Deprecated in OS X v10.7.)

Boolean MPTaskIsPreemptive (

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

84

Page 85: Apple manual

MPTaskID taskID);

ParameterstaskID

The task you want to check. Pass kMPNoID or kInvalidID if you want to specify the current task.

Return ValueIf true, the task is preemptively scheduled. If false, the task is cooperatively scheduled.

DiscussionIf you have code that may be called from either cooperative or preemptive tasks, that code can callMPTaskIsPreemptive if its actions should differ depending on its execution environment.

Note that you can call this function from an interrupt handler.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPTerminateTask

Terminates an existing task. (Deprecated in OS X v10.7.)

OSStatus MPTerminateTask (MPTaskID task,OSStatus terminationStatus

);

Parameterstask

The ID of the task you wish to terminate.

terminationStatusA value of type OSStatus indicating termination status. This value is sent to the termination statusmessage queue you specified in MPCreateTask (page 53) in place of the task function’s result code.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

85

Page 86: Apple manual

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41). If the task to be terminated is already inthe process of termination, MPTerminateTask returns kMPInsufficientResourcesErr. You do not needto take any additional action if this occurs.

DiscussionYou should be very careful when calling MPTerminateTask. As defined, this call will asynchronously andabruptly terminate a task, potentially leaving whatever structures or resources it was operating upon in anindeterminate state. OS X exacerbates this problem, as MP tasks can use many more system services that arenot expecting client threads to asynchronously terminate, and these services do not take the rather complicatedsteps necessary to protect against, or recover from, such a situation.

However, there are situations in which calling MPTerminateTask is useful and relatively safe. One suchsituation is when your application or service is quitting and you know that the task you wish to terminate iswaiting on an MP synchronization construct (queue, event, semaphore or critical region). While you could dothis more cleanly by waking the task and causing it to exit on its own, doing so may not always be practical.

For example, suppose you have several service tasks performing background processing for your application.These service tasks wait on a queue, onto which the application places requests for processing. When the taskis done with a request, it notifies another queue, which the application polls. Since the main application taskis placing items on the shared queue, and receiving notifications when the requests are done, it can trackwhether or not there are outstanding requests being processed. If all outstanding requests have, in fact, beenprocessed, it is relatively safe to terminate a task (or all tasks) waiting on the request queue.

You should not assume that the task has completed termination when this call returns; the proper way tosynchronize with task termination is to wait on the termination queue (specified in MPCreateTask (page 53) )until a message appears. Because task termination is a multistage activity, it is possible for a preemptive taskto attempt to terminate a task that is already undergoing termination. In such cases, MPTerminateTaskreturns kMPInsufficientResourcesErr.

Note that Multiprocessing Services resources (event groups, queues, semaphores, and critical regions) ownedby a preemptive task are not released when that task terminates. If a task has a critical region locked when itterminates, the critical region remains in the locked state. Multiprocessing Services resources no longer neededshould be explicitly deleted by the task that handles the termination message. All Multiprocessing Servicesresources created by tasks are released when their owning process (that is, the host application) terminates.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

86

Page 87: Apple manual

Declared inMultiprocessing.h

MPThrowException

Throws an exception to a specified task. (Deprecated in OS X v10.7.)

OSStatus MPThrowException (MPTaskID task,MPExceptionKind kind

);

Parameterstask

The task to which the exception should be thrown.

kindThe type of exception to give to the task.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41). If the task is already suspended or if thetask is not defined to take thrown exceptions, the function returns kMPInsufficientResourcesErr.

DiscussionThe exception is treated in the same manner as any other exception taken by a task. However, since it isasynchronous, it may not be presented immediately.

By convention, you should set the exception kind to kMPTaskStoppedErr if you want to suspend a task. Ingeneral, you should do so only if you are debugging and wish to examine the state of the task. Otherwise youshould block the task using one of the traditional notification mechanisms (such as a message queue).

An exception can be thrown at any time, whether that task is running, eligible to be run (that is, ready), orblocked. The task is suspended and an exception message may be generated the next time the task is aboutto run. Note that this may never occur— for example, if the task is deadlocked or the resource it is waiting onis never released. If the task is currently blocked when this function is executed, kMPTaskBlockedErr isreturned. If the task was suspended immediately at the conclusion of this function call the return value iskMPTaskStoppedErr.

In OS X, this function is available but is not implemented.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

87

Page 88: Apple manual

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPUnregisterDebugger

Unregisters a debugger. (Deprecated in OS X v10.7.)

OSStatus MPUnregisterDebugger (MPQueueID queue

);

Parametersqueue

The ID of the queue whose debugger you want to unregister.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionIn OS X, this function is available but is not implemented. Use system debugging services to write a debuggerfor OS X.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPWaitForEvent

Retrieves event flags from a specified event group. (Deprecated in OS X v10.7.)

OSStatus MPWaitForEvent (MPEventID event,MPEventFlags *flags,Duration timeout

);

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

88

Page 89: Apple manual

Parametersevent

The event group whose flags you want to retrieve.

flagsOn return, flags contains the flags of the specified event group. Pass NULL if you do not need any flaginformation.

timeoutThe maximum time to wait for events before timing out. See “Timer Duration Constants” (page 40) fora list of constants you can use to specify the wait interval.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionThis function obtains event flags from the specified event group. The timeout specifies how long to wait forevents if none are present when the call is made. If any flags are set when this function is called, all the flagsin the event group are moved to the flag field and the event group is cleared. This obtaining and clearingaction is an atomic operation to ensure that no updates are lost. If multiple tasks are waiting on an event group,only one can obtain any particular set of flags.

If you call this function from a cooperative task, you should specify only kDurationImmediate for the timeoutlength; other waits will cause the task to block.

Also see the function MPSetEvent (page 77).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPWaitOnQueue

Obtains a message from a specified message queue. (Deprecated in OS X v10.7.)

OSStatus MPWaitOnQueue (MPQueueID queue,void **param1,void **param2,void **param3,

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

89

Page 90: Apple manual

Duration timeout);

Parametersqueue

The ID of the message queue from which to receive the notification.

param1On return, the first pointer-sized value of the notification message. Pass NULL if you do not need thisportion of the message.

param2On return, the second pointer-sized value of the notification message. Pass NULL if you do not need thisportion of the message.

param3On return, the third pointer-sized value of the notification message. Pass NULL if you do not need thisportion of the message.

timeoutThe time to wait for a notification before timing out. See “Timer Duration Constants” (page 40) for a listof constants you can use to specify the wait interval.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionThis function receives a message from the specified message queue. If no messages are currently available,the timeout specifies how long the function should wait for one. Tasks waiting on the queue are handled in afirst in, first out manner; that is, the first task to wait on the queue receives the message from theMPNotifyQueue (page 72) call.

After calling this function, when a message appears, it is removed from the queue and the three fields, param1,param2, and param3 are set to the values specified by the message text. Note these parameters are pointersto variables to be set with the message text.

If you call this function from a cooperative task, you should specify only kDurationImmediate for the timeoutlength; other waits will cause the task to block.

Also see the function MPNotifyQueue (page 72).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

90

Page 91: Apple manual

Declared inMultiprocessing.h

MPWaitOnSemaphore

Waits on a semaphore (Deprecated in OS X v10.7.)

OSStatus MPWaitOnSemaphore (MPSemaphoreID semaphore,Duration timeout

);

Parameterssemaphore

The ID of the semaphore you want to wait on.

timeoutThe maximum time the function should wait before timing out. See “Timer Duration Constants” (page40) for a list of constants you can use to specify the wait interval.

Return ValueA result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionIf the value of the semaphore is greater than zero, the value is decremented and the function returns withnoErr. Otherwise, the task is blocked awaiting a signal until the specified timeout is exceeded.

If you call this function from a cooperative task, you should specify only kDurationImmediate for the timeoutlength; other waits will cause the task to block.

Also see the function MPSignalSemaphore (page 84).

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

MPYield

Allows a task to yield the processor to another task. (Deprecated in OS X v10.7.)

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.7

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

91

Page 92: Apple manual

void MPYield (void

);

DiscussionThis function indicates to the scheduler that another task can run. Other than possibly yielding the processorto another task or application, the call has no effect. Note that since tasks are preemptively scheduled, animplicit yield may occur at any point, whether or not this function is called.

In most cases you should not need to call this function. The most common use of MPYield is to release theprocessor when a task is in a loop in which further progress is dependent on other tasks, and the task cannotbe blocked by waiting on a Multiprocessing Services resource. You should avoid such busy waiting wheneverpossible.

Note that you can call this function from an interrupt handler.

AvailabilityAvailable in OS X v10.0 and later.

Deprecated in OS X v10.7.

Declared inMultiprocessing.h

Deprecated in OS X v10.8

MPSetTaskType

Sets the type of the task. (Deprecated in OS X v10.8.)

OSStatus MPSetTaskType (MPTaskID task,OSType taskType

);

Return ValueThe noErr result code. See “Multiprocessing Services Result Codes” (page 41).

DiscussionThis function does nothing and should not be used.

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.8

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

92

Page 93: Apple manual

AvailabilityAvailable in OS X v10.1 and later.

Deprecated in OS X v10.8.

Declared inMultiprocessing.h

Deprecated Multiprocessing Services FunctionsDeprecated in OS X v10.8

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

93

Page 94: Apple manual

This table describes the changes to Multiprocessing Services Reference .

NotesDate

Updated to describe replacement functionality for symbols deprecatedin OS X v10.8.

2012-07-23

Updated the description of the MPRemoteCall function.2008-02-08

Updated for OS X v10.5.2007-10-31

Made minor technical corrections.2005-07-07

Updated formatting and linking.2003-02-01

2012-07-23 | © 2012 Apple Inc. All Rights Reserved.

94

Document Revision History

Page 95: Apple manual

Apple Inc.© 2012 Apple Inc.All rights reserved.

No part of this publication may be reproduced,stored in a retrieval system, or transmitted, in anyform or by any means, mechanical, electronic,photocopying, recording, or otherwise, withoutprior written permission of Apple Inc., with thefollowing exceptions: Any person is herebyauthorized to store documentation on a singlecomputer for personal use only and to printcopies of documentation for personal useprovided that the documentation containsApple’s copyright notice.

No licenses, express or implied, are granted withrespect to any of the technology described in thisdocument. Apple retains all intellectual propertyrights associated with the technology describedin this document. This document is intended toassist application developers to developapplications only for Apple-labeled computers.

Apple Inc.1 Infinite LoopCupertino, CA 95014408-996-1010

Apple, the Apple logo, Carbon, eMac, Logic, Mac,Mac OS, OS X, and QuickTime are trademarks ofApple Inc., registered in the U.S. and othercountries.

PowerPC and the PowerPC logo are trademarksof International Business Machines Corporation,used under license therefrom.

Even though Apple has reviewed this document,APPLE MAKES NO WARRANTY OR REPRESENTATION,EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THISDOCUMENT, ITS QUALITY, ACCURACY,MERCHANTABILITY, OR FITNESS FOR A PARTICULARPURPOSE.ASARESULT, THISDOCUMENT ISPROVIDED“AS IS,” AND YOU, THE READER, ARE ASSUMING THEENTIRE RISK AS TO ITS QUALITY AND ACCURACY.

IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT,INDIRECT, SPECIAL, INCIDENTAL, ORCONSEQUENTIALDAMAGES RESULTING FROM ANY DEFECT ORINACCURACY IN THIS DOCUMENT, even if advised ofthe possibility of such damages.

THE WARRANTY AND REMEDIES SET FORTH ABOVEARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORALOR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer,agent, or employee is authorized to make anymodification, extension, or addition to this warranty.

Some states do not allow the exclusion or limitationof implied warranties or liability for incidental orconsequential damages, so the above limitation orexclusion may not apply to you. This warranty givesyou specific legal rights, and youmay also have otherrights which vary from state to state.