Go to the first, previous, next, last section, table of contents.


Thread Creation

Function: kern_return_t thread_create (mach_port_t parent_task, mach_port_t *child_thread)
The function thread_create creates a new thread within the task specified by parent_task. The new thread has no processor state, and has a suspend count of 1. To get a new thread to run, first thread_create is called to get the new thread's identifier, (child_thread). Then thread_set_state is called to set a processor state, and finally thread_resume is called to get the thread scheduled to execute.

When the thread is created send rights to its thread kernel port are given to it and returned to the caller in child_thread. The new thread's exception port is set to MACH_PORT_NULL.

The function returns KERN_SUCCESS if a new thread has been created, KERN_INVALID_ARGUMENT if parent_task is not a valid task and KERN_RESOURCE_SHORTAGE if some critical kernel resource is not available.


Go to the first, previous, next, last section, table of contents.