xref: /xnu-8792.81.2/osfmk/man/task_create.html (revision 19c3b8c28c31cb8130e034cfb5df6bf9ba342d90)
1*19c3b8c2SApple OSS Distributions<h2>task_create</h2>
2*19c3b8c2SApple OSS Distributions<hr>
3*19c3b8c2SApple OSS Distributions<p>
4*19c3b8c2SApple OSS Distributions<strong>Function</strong> - Create a new task.
5*19c3b8c2SApple OSS Distributions<h3>SYNOPSIS</h3>
6*19c3b8c2SApple OSS Distributions<pre>
7*19c3b8c2SApple OSS Distributions<strong>kern_return_t   task_create</strong>
8*19c3b8c2SApple OSS Distributions                <strong>(task_t</strong>                             <var>parent_task</var>,
9*19c3b8c2SApple OSS Distributions                 <strong>ledger_port_array_t</strong>                    <var>ledgers</var>,
10*19c3b8c2SApple OSS Distributions                 <strong>int</strong>                               <var>ledger_count</var>,
11*19c3b8c2SApple OSS Distributions                 <strong>boolean_t</strong>                       <var>inherit_memory</var>,
12*19c3b8c2SApple OSS Distributions                 <strong>task_t</strong>                              <var>child_task</var><strong>);</strong>
13*19c3b8c2SApple OSS Distributions</pre>
14*19c3b8c2SApple OSS Distributions<h3>PARAMETERS</h3>
15*19c3b8c2SApple OSS Distributions<dl>
16*19c3b8c2SApple OSS Distributions<p>
17*19c3b8c2SApple OSS Distributions<dt> <var>parent_task</var>
18*19c3b8c2SApple OSS Distributions<dd>
19*19c3b8c2SApple OSS Distributions[in task send right]
20*19c3b8c2SApple OSS DistributionsThe port for the task from which to draw the child
21*19c3b8c2SApple OSS Distributionstask's port rights and address space.
22*19c3b8c2SApple OSS Distributions<p>
23*19c3b8c2SApple OSS Distributions<dt> <var>ledgers</var>
24*19c3b8c2SApple OSS Distributions<dd>
25*19c3b8c2SApple OSS Distributions[pointer to in array of ledger send rights]
26*19c3b8c2SApple OSS DistributionsResource ledgers (on the
27*19c3b8c2SApple OSS Distributionsdestination host) from which the task will draw its resources.  The first
28*19c3b8c2SApple OSS Distributionselement of this array is the wired kernel ledger, the second the paged
29*19c3b8c2SApple OSS Distributionsspace ledger.  If the number of ledgers supplied does not match the
30*19c3b8c2SApple OSS Distributionsrequired number or one or more is null, the parent task's ledger is used.
31*19c3b8c2SApple OSS Distributions<p>
32*19c3b8c2SApple OSS Distributions<dt> <var>ledger_count</var>
33*19c3b8c2SApple OSS Distributions<dd>
34*19c3b8c2SApple OSS Distributions[in scalar]
35*19c3b8c2SApple OSS DistributionsThe number of ledger ports in the <var>ledgers</var> array.
36*19c3b8c2SApple OSS Distributions<p>
37*19c3b8c2SApple OSS Distributions<dt> <var>inherit_memory</var>
38*19c3b8c2SApple OSS Distributions<dd>
39*19c3b8c2SApple OSS Distributions[in scalar]
40*19c3b8c2SApple OSS DistributionsAddress space inheritance indicator.  If true, the child task
41*19c3b8c2SApple OSS Distributionsinherits the (inheritable) address space of the parent task.  If false, the
42*19c3b8c2SApple OSS Distributionskernel assigns the child task an empty address space.
43*19c3b8c2SApple OSS Distributions<p>
44*19c3b8c2SApple OSS Distributions<dt> <var>child_task</var>
45*19c3b8c2SApple OSS Distributions<dd>
46*19c3b8c2SApple OSS Distributions[out task send right]
47*19c3b8c2SApple OSS DistributionsThe kernel-assigned port for the new task.
48*19c3b8c2SApple OSS Distributions</dl>
49*19c3b8c2SApple OSS Distributions<h3>DESCRIPTION</h3>
50*19c3b8c2SApple OSS Distributions<p>
51*19c3b8c2SApple OSS DistributionsThe <strong>task_create</strong> function creates a new task from <var>parent_task</var>
52*19c3b8c2SApple OSS Distributionsand returns the name of the new task in <var>child_task</var>.
53*19c3b8c2SApple OSS DistributionsThe child task acquires shared or copied parts of the parent's address space
54*19c3b8c2SApple OSS Distributions(see <strong>vm_inherit</strong>).  The child task initially
55*19c3b8c2SApple OSS Distributionscontains no threads.  The child task inherits the parent's security ID.
56*19c3b8c2SApple OSS Distributions<p>
57*19c3b8c2SApple OSS DistributionsThe child task receives the following "special" ports, which are created or
58*19c3b8c2SApple OSS Distributionscopied for it at task creation:
59*19c3b8c2SApple OSS Distributions<dl>
60*19c3b8c2SApple OSS Distributions<dt> [task-self send right]
61*19c3b8c2SApple OSS Distributions<dd>
62*19c3b8c2SApple OSS DistributionsThe port by which the kernel knows the new child task
63*19c3b8c2SApple OSS Distributionsand allows it to be manipulated.  The child task holds a send right for this
64*19c3b8c2SApple OSS Distributionsport.  The port name is also returned to the calling task.
65*19c3b8c2SApple OSS Distributions<p>
66*19c3b8c2SApple OSS Distributions<dt> [bootstrap send right]
67*19c3b8c2SApple OSS Distributions<dd>
68*19c3b8c2SApple OSS DistributionsThe port to which the child task can send a message
69*19c3b8c2SApple OSS Distributionsrequesting return of any system service ports that it needs (for
70*19c3b8c2SApple OSS Distributionsexample, a port
71*19c3b8c2SApple OSS Distributionsto the Network Name Server or the Environment Manager).  The child task
72*19c3b8c2SApple OSS Distributionsinherits a send right for this port from the parent task.  The task can use
73*19c3b8c2SApple OSS Distributions<strong>task_set_special_port</strong> to change this port.
74*19c3b8c2SApple OSS Distributions<p>
75*19c3b8c2SApple OSS Distributions<dt> [host-self send right]
76*19c3b8c2SApple OSS Distributions<dd>
77*19c3b8c2SApple OSS DistributionsThe port by which the child task requests information
78*19c3b8c2SApple OSS Distributionsabout its host.  The child task inherits a send right for this port from the
79*19c3b8c2SApple OSS Distributionsparent task.
80*19c3b8c2SApple OSS Distributions<p>
81*19c3b8c2SApple OSS Distributions<dt> [ledger send rights]
82*19c3b8c2SApple OSS Distributions<dd>
83*19c3b8c2SApple OSS DistributionsThe ports naming the ledgers from which the task draws
84*19c3b8c2SApple OSS Distributionsits resources.
85*19c3b8c2SApple OSS Distributions</dl>
86*19c3b8c2SApple OSS Distributions<p>
87*19c3b8c2SApple OSS DistributionsThe child task also inherits the following ports:
88*19c3b8c2SApple OSS Distributions<dl>
89*19c3b8c2SApple OSS Distributions<dt> [sample send right]
90*19c3b8c2SApple OSS Distributions<dd>
91*19c3b8c2SApple OSS DistributionsThe port to which PC sampling messages are to be sent.
92*19c3b8c2SApple OSS Distributions<p>
93*19c3b8c2SApple OSS Distributions<dt> [exception send rights]
94*19c3b8c2SApple OSS Distributions<dd>
95*19c3b8c2SApple OSS DistributionsPorts to which exception messages are sent.
96*19c3b8c2SApple OSS Distributions<p>
97*19c3b8c2SApple OSS Distributions<dt> [registered send rights]
98*19c3b8c2SApple OSS Distributions<dd>
99*19c3b8c2SApple OSS DistributionsPorts to system services.
100*19c3b8c2SApple OSS Distributions</dl>
101*19c3b8c2SApple OSS Distributions<h3>NOTES</h3>
102*19c3b8c2SApple OSS Distributions<p>
103*19c3b8c2SApple OSS DistributionsThe <strong>ledgers</strong> functionality mentioned above is not
104*19c3b8c2SApple OSS Distributionscurrently implemented.
105*19c3b8c2SApple OSS Distributions<h3>RETURN VALUES</h3>
106*19c3b8c2SApple OSS Distributions<p>
107*19c3b8c2SApple OSS DistributionsOnly generic errors apply.
108*19c3b8c2SApple OSS Distributions<h3>RELATED INFORMATION</h3>
109*19c3b8c2SApple OSS Distributions<p>
110*19c3b8c2SApple OSS DistributionsFunctions:
111*19c3b8c2SApple OSS Distributions<a href="task_create_security_token.html"><strong>task_create_security_token</strong></a>,
112*19c3b8c2SApple OSS Distributions<a href="task_resume.html"><strong>task_resume</strong></a>,
113*19c3b8c2SApple OSS Distributions<a href="task_set_special_port.html"><strong>task_set_special_port</strong></a>,
114*19c3b8c2SApple OSS Distributions<a href="task_suspend.html"><strong>task_suspend</strong></a>,
115*19c3b8c2SApple OSS Distributions<a href="task_terminate.html"><strong>task_terminate</strong></a>,
116*19c3b8c2SApple OSS Distributions<a href="task_threads.html"><strong>task_threads</strong></a>,
117*19c3b8c2SApple OSS Distributions<a href="thread_create.html"><strong>thread_create</strong></a>,
118*19c3b8c2SApple OSS Distributions<a href="thread_resume.html"><strong>thread_resume</strong></a>,
119*19c3b8c2SApple OSS Distributions<a href="vm_inherit.html"><strong>vm_inherit</strong></a>,
120*19c3b8c2SApple OSS Distributions<a href="task_sample.html"><strong>task_sample</strong></a>,
121*19c3b8c2SApple OSS Distributions<a href="task_set_exception_ports.html"><strong>task_set_exception_ports</strong></a>,
122*19c3b8c2SApple OSS Distributions<a href="mach_ports_register.html"><strong>mach_ports_register</strong></a>,
123*19c3b8c2SApple OSS Distributions<a href="host_security_set_task_token.html"><strong>host_security_set_task_token</strong></a>.
124