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