Next: Thread Termination, Up: Thread Interface
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, firstthread_create
is called to get the new thread's identifier, (child_thread). Thenthread_set_state
is called to set a processor state, and finallythread_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 andKERN_RESOURCE_SHORTAGE
if some critical kernel resource is not available.