## thread_create_running

Function - Optimized creation of a running thread.

### SYNOPSIS

    kern_return_t   thread_create_running
                    (task_t                             parent_task,
                     thread_state_flavor_t                   flavor,
                     thread_state_t                           state,
                     thread_act_t                      child_thread);

### PARAMETERS

parent_task
  [in task send right] The port for the task that is to contain the new thread.

flavor
  [in scalar] The type of state to establish. Valid values correspond to supported machine architecture features.

state
  [pointer to in structure] State information for the specified thread.

child_thread
  [out thread send right] The kernel-assigned name for the new thread.

### DESCRIPTION

The thread_create_running function creates a new thread within parent_task. The new thread has is not suspended. Its initial state is given by state. flavor specifies the type of state to set.

The format of the state to set is machine specific; it is defined in \*L\*O.

The new thread holds a send right for its thread kernel port. A send right for the thread's kernel port is also returned to the calling task or thread in child_thread. The new thread's exception ports are set to MACH_PORT_NULL.

### NOTES

This is an optimized form of the sequence: thread_create, thread_set_state and thread_resume.

### RETURN VALUES

Only generic errors apply.

### RELATED INFORMATION

Functions: task_create, task_threads, thread_get_special_port, thread_get_state, thread_resume, thread_set_special_port, thread_set_state, thread_suspend, thread_terminate, thread_create.