xref: /xnu-11215.41.3/osfmk/man/thread_create.html (revision 33de042d024d46de5ff4e89f2471de6608e37fa4)
1*33de042dSApple OSS Distributions<h2>thread_create</h2>
2*33de042dSApple OSS Distributions<hr>
3*33de042dSApple OSS Distributions<p>
4*33de042dSApple OSS Distributions<strong>Function</strong> - Create a thread within a task.
5*33de042dSApple OSS Distributions<h3>SYNOPSIS</h3>
6*33de042dSApple OSS Distributions<pre>
7*33de042dSApple OSS Distributions<strong>kern_return_t   thread_create</strong>
8*33de042dSApple OSS Distributions                <strong>(task_t</strong>                             <var>parent_task</var>,
9*33de042dSApple OSS Distributions                 <strong>thread_act_t</strong>                      <var>child_thread</var><strong>);</strong>
10*33de042dSApple OSS Distributions</pre>
11*33de042dSApple OSS Distributions<h3>PARAMETERS</h3>
12*33de042dSApple OSS Distributions<dl>
13*33de042dSApple OSS Distributions<p>
14*33de042dSApple OSS Distributions<dt> <var>parent_task</var>
15*33de042dSApple OSS Distributions<dd>
16*33de042dSApple OSS Distributions[in task send right]
17*33de042dSApple OSS DistributionsThe port for the task that is to contain the new
18*33de042dSApple OSS Distributionsthread.
19*33de042dSApple OSS Distributions<p>
20*33de042dSApple OSS Distributions<dt> <var>child_thread</var>
21*33de042dSApple OSS Distributions<dd>
22*33de042dSApple OSS Distributions[out thread send right]
23*33de042dSApple OSS DistributionsThe kernel-assigned name for the new thread.
24*33de042dSApple OSS Distributions</dl>
25*33de042dSApple OSS Distributions<h3>DESCRIPTION</h3>
26*33de042dSApple OSS Distributions<p>
27*33de042dSApple OSS DistributionsThe <strong>thread_create</strong> function creates a new thread within
28*33de042dSApple OSS Distributions<var>parent_task</var>.  The new thread has a suspend count of one and
29*33de042dSApple OSS Distributionsno processor state.
30*33de042dSApple OSS Distributions<p>
31*33de042dSApple OSS DistributionsThe new thread holds a send right for its thread kernel port.
32*33de042dSApple OSS DistributionsA send right for the
33*33de042dSApple OSS Distributionsthread's kernel port is also returned to the calling task or
34*33de042dSApple OSS Distributionsthread in <var>child_thread</var>.
35*33de042dSApple OSS DistributionsThe new thread's exception ports are set to <strong>MACH_PORT_NULL</strong>.
36*33de042dSApple OSS Distributions<h3>NOTES</h3>
37*33de042dSApple OSS Distributions<p>
38*33de042dSApple OSS DistributionsTo get a new thread running, first use <strong>thread_set_state</strong>
39*33de042dSApple OSS Distributionsto set a processor state
40*33de042dSApple OSS Distributionsfor the thread.  Then, use <strong>thread_resume</strong> to schedule
41*33de042dSApple OSS Distributionsthe thread for execution.
42*33de042dSApple OSS DistributionsAlternately, use <strong>thread_create_running</strong>.
43*33de042dSApple OSS Distributions<h3>RETURN VALUES</h3>
44*33de042dSApple OSS Distributions<p>
45*33de042dSApple OSS DistributionsOnly generic errors apply.
46*33de042dSApple OSS Distributions<h3>RELATED INFORMATION</h3>
47*33de042dSApple OSS Distributions<p>
48*33de042dSApple OSS DistributionsFunctions:
49*33de042dSApple OSS Distributions<a href="task_create.html"><strong>task_create</strong></a>,
50*33de042dSApple OSS Distributions<a href="task_threads.html"><strong>task_threads</strong></a>,
51*33de042dSApple OSS Distributions<a href="thread_get_special_port.html"><strong>thread_get_special_port</strong></a>,
52*33de042dSApple OSS Distributions<a href="thread_get_state.html"><strong>thread_get_state</strong></a>,
53*33de042dSApple OSS Distributions<a href="thread_resume.html"><strong>thread_resume</strong></a>,
54*33de042dSApple OSS Distributions<a href="thread_set_special_port.html"><strong>thread_set_special_port</strong></a>,
55*33de042dSApple OSS Distributions<a href="thread_set_state.html"><strong>thread_set_state</strong></a>,
56*33de042dSApple OSS Distributions<a href="thread_suspend.html"><strong>thread_suspend</strong></a>,
57*33de042dSApple OSS Distributions<a href="thread_terminate.html"><strong>thread_terminate</strong></a>,
58*33de042dSApple OSS Distributions<a href="thread_create_running.html"><strong>thread_create_running</strong></a>.
59