Next: Thread Termination, Up: Thread Interface
The function
thread_createcreates 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_createis called to get the new thread's identifier, (child_thread). Thenthread_set_stateis called to set a processor state, and finallythread_resumeis 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_SUCCESSif a new thread has been created,KERN_INVALID_ARGUMENTif parent_task is not a valid task andKERN_RESOURCE_SHORTAGEif some critical kernel resource is not available.