270 |
return KERN_SUCCESS; |
return KERN_SUCCESS; |
271 |
} |
} |
272 |
|
|
273 |
|
/* Return send rights to threads that belong to TASK. Send rights |
274 |
|
are returned in THREADSP. Number of ports returned in *COUNTP. */ |
275 |
|
kern_return_t |
276 |
|
task_threads (struct task *task, rtmk_port_t **threadsp, int *countp) |
277 |
|
{ |
278 |
|
struct ipc_port **ports; |
279 |
|
struct thread *thread; |
280 |
|
int count = 0, i = 0; |
281 |
|
SPL_T spl; |
282 |
|
|
283 |
|
assert (task); |
284 |
|
|
285 |
|
spl = SPLOFF (); |
286 |
|
task_lock (task); |
287 |
|
|
288 |
|
/* First we count all threads in the task so that we get the |
289 |
|
amount of memory we must allocate for the port array. */ |
290 |
|
queue_iterate (&task->thread_list, thread, struct thread *, taskq) |
291 |
|
count++; |
292 |
|
|
293 |
|
/* Allocate memory (not wired) for the array. */ |
294 |
|
ports = |
295 |
|
(struct ipc_port **) kmem_malloc (count * sizeof (struct ipc_port *)); |
296 |
|
|
297 |
|
queue_iterate (&task->thread_list, thread, struct thread *, taskq) |
298 |
|
ports [i++] = thread->thread_port; |
299 |
|
|
300 |
|
task_unlock (task); |
301 |
|
SPLON (spl); |
302 |
|
|
303 |
|
*threadsp = (rtmk_port_t *) ports; |
304 |
|
*countp = count; |
305 |
|
return KERN_SUCCESS; |
306 |
|
} |