Next: , Up: Task Interface

7.2.1 Task Creation

— Function: kern_return_t task_create (task_t parent_task, boolean_t inherit_memory, task_t *child_task)

The function task_create creates a new task from parent_task; the resulting task (child_task) acquires shared or copied parts of the parent's address space (see vm_inherit). The child task initially contains no threads.

If inherit_memory is set, the child task's address space is built from the parent task according to its memory inheritance values; otherwise, the child task is given an empty address space.

The child task gets the three special ports created or copied for it at task creation. The TASK_KERNEL_PORT is created and send rights for it are given to the child and returned to the caller. The TASK_BOOTSTRAP_PORT and the TASK_EXCEPTION_PORT are inherited from the parent task. The new task can get send rights to these ports with the call task_get_special_port.

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