Next: , Previous: Processor Set Destruction, Up: Processor Set Interface


9.1.5 Tasks and Threads on Sets

— Function: kern_return_t processor_set_tasks (processor_set_t processor_set, task_array_t *task_list, mach_msg_type_number_t *task_count)

The function processor_set_tasks gets send rights to the kernel port for each task currently assigned to processor_set.

task_list is an array that is created as a result of this call. The caller may wish to vm_deallocate this array when the data is no longer needed. task_count is set to the number of tasks in the task_list.

This function returns KERN_SUCCESS if the call succeeded and KERN_INVALID_ARGUMENT if processor_set is not a processor set.

— Function: kern_return_t processor_set_threads (processor_set_t processor_set, thread_array_t *thread_list, mach_msg_type_number_t *thread_count)

The function processor_set_thread gets send rights to the kernel port for each thread currently assigned to processor_set.

thread_list is an array that is created as a result of this call. The caller may wish to vm_deallocate this array when the data is no longer needed. thread_count is set to the number of threads in the thread_list.

This function returns KERN_SUCCESS if the call succeeded and KERN_INVALID_ARGUMENT if processor_set is not a processor set.

— Function: kern_return_t task_assign (task_t task, processor_set_t processor_set, boolean_t assign_threads)

The function task_assign assigns task the set processor_set. This assignment is for the purposes of determining the initial assignment of newly created threads in task. Any previous assignment of the task is nullified. Existing threads within the task are also reassigned if assign_threads is TRUE. They are not affected if it is FALSE.

This function returns KERN_SUCCESS if the assignment has been performed and KERN_INVALID_ARGUMENT if task is not a task, or processor_set is not a processor set on the same host as task.

— Function: kern_return_t task_assign_default (task_t task, boolean_t assign_threads)

The function task_assign_default is a variant of task_assign that assigns the task to the default processor set on that task's host. This variant exists because the control port for the default processor set is privileged and not usually available to users.

This function returns KERN_SUCCESS if the assignment has been performed and KERN_INVALID_ARGUMENT if task is not a task.

— Function: kern_return_t task_get_assignment (task_t task, processor_set_name_t *assigned_set)

The function task_get_assignment returns the name of the processor set to which the thread is currently assigned in assigned_set. This port can only be used to obtain information about the processor set.

This function returns KERN_SUCCESS if the assignment has been performed, KERN_INVALID_ADDRESS if processor_set points to inaccessible memory, and KERN_INVALID_ARGUMENT if task is not a task.

— Function: kern_return_t thread_assign (thread_t thread, processor_set_t processor_set)

The function thread_assign assigns thread the set processor_set. After the assignment is completed, the thread only executes on processors assigned to the designated processor set. If there are no such processors, then the thread is unable to execute. Any previous assignment of the thread is nullified. Unix system call compatibility code may temporarily force threads to execute on the master processor.

This function returns KERN_SUCCESS if the assignment has been performed and KERN_INVALID_ARGUMENT if thread is not a thread, or processor_set is not a processor set on the same host as thread.

— Function: kern_return_t thread_assign_default (thread_t thread)

The function thread_assign_default is a variant of thread_assign that assigns the thread to the default processor set on that thread's host. This variant exists because the control port for the default processor set is privileged and not usually available to users.

This function returns KERN_SUCCESS if the assignment has been performed and KERN_INVALID_ARGUMENT if thread is not a thread.

— Function: kern_return_t thread_get_assignment (thread_t thread, processor_set_name_t *assigned_set)

The function thread_get_assignment returns the name of the processor set to which the thread is currently assigned in assigned_set. This port can only be used to obtain information about the processor set.

This function returns KERN_SUCCESS if the assignment has been performed, KERN_INVALID_ADDRESS if processor_set points to inaccessible memory, and KERN_INVALID_ARGUMENT if thread is not a thread.