23 |
#include "tm.h" |
#include "tm.h" |
24 |
#include "task.h" |
#include "task.h" |
25 |
#include "vm-slab.h" |
#include "vm-slab.h" |
26 |
|
#include "vm-kmem.h" |
27 |
#include "trace.h" |
#include "trace.h" |
28 |
#include "ipc-object.h" |
#include "ipc-object.h" |
29 |
#include "thread.h" |
#include "thread.h" |
37 |
|
|
38 |
/* Create a new task. Inherit memory from PARENT_TASK if INHERIT_MEMORY_P |
/* Create a new task. Inherit memory from PARENT_TASK if INHERIT_MEMORY_P |
39 |
is true. New task is returned in CHILD_TASKP. */ |
is true. New task is returned in CHILD_TASKP. */ |
|
|
|
40 |
kern_return_t |
kern_return_t |
41 |
task_create (struct task *parent_task, bool inherit_memory_p, |
task_create (struct task *parent_task, bool inherit_memory_p, |
42 |
struct task **child_taskp) |
struct task **child_taskp) |
67 |
return KERN_RESOURCE_SHORTAGE; |
return KERN_RESOURCE_SHORTAGE; |
68 |
} |
} |
69 |
|
|
70 |
/* We inherit send rights to the special ports. */ |
if (parent_task) |
|
for (i = 0; i < 8 && parent_task; i++) |
|
71 |
{ |
{ |
72 |
if (parent_task->special_ports [i]) |
if (parent_task->exception_port) |
73 |
{ |
{ |
74 |
new_task->special_ports [i] |
new_task->exception_port |
75 |
= ipc_port_copy_send (parent_task->special_ports [i]); |
= ipc_port_copy_send (parent_task->exception_port); |
76 |
} |
} |
|
} |
|
77 |
|
|
78 |
|
/* We inherit send rights to the special ports. */ |
79 |
|
for (i = 0; i < 8; i++) |
80 |
|
{ |
81 |
|
if (parent_task->special_ports [i]) |
82 |
|
{ |
83 |
|
new_task->special_ports [i] |
84 |
|
= ipc_port_copy_send (parent_task->special_ports [i]); |
85 |
|
} |
86 |
|
} |
87 |
|
} |
88 |
|
|
89 |
queue_init (&new_task->thread_list); |
queue_init (&new_task->thread_list); |
90 |
new_task->ipc_object = ipc_object_create (); |
new_task->ipc_object = ipc_object_create (); |
213 |
switch (slot) |
switch (slot) |
214 |
{ |
{ |
215 |
case TASK_SPECIAL_PORT_KERNEL: |
case TASK_SPECIAL_PORT_KERNEL: |
216 |
slotp = & task->task_port; |
slotp = & task->send_task_port; |
217 |
|
break; |
218 |
|
case TASK_SPECIAL_PORT_EXCEPTION: |
219 |
|
slotp = & task->exception_port; |
220 |
break; |
break; |
221 |
default: |
default: |
222 |
slotp = & task->special_ports [slot]; |
slotp = & task->special_ports [slot]; |
254 |
switch (slot) |
switch (slot) |
255 |
{ |
{ |
256 |
case TASK_SPECIAL_PORT_KERNEL: |
case TASK_SPECIAL_PORT_KERNEL: |
257 |
slotp = & task->task_port; |
slotp = & task->send_task_port; |
258 |
|
break; |
259 |
|
case TASK_SPECIAL_PORT_EXCEPTION: |
260 |
|
slotp = & task->exception_port; |
261 |
break; |
break; |
262 |
default: |
default: |
263 |
slotp = & task->special_ports [slot]; |
slotp = & task->special_ports [slot]; |
269 |
|
|
270 |
return KERN_SUCCESS; |
return KERN_SUCCESS; |
271 |
} |
} |
272 |
|
|