TASK_DESTROY
Purpose
task_destroy destroys a task.
Synopsis
#include <types.h>
#include <stub.h>
int task_destroy(Capability
*task, int exit_status);
Parameters
-
task: the capability for the task
to be destroyed;
-
exit_status: the status to be returned
to the thread calling task_wait.
Description
task_destroy destroys the task designated
by task. Destroying a task includes destroying all of its threads.
Its data and code segments are detached
and destroyed if no one else is sharing it (the loader
automatically shares de code segment for new invocations of the same program).
Other objects, like mailboxes, semaphores and interrupts are not automatically
destroyed. One of the task's threads must explicitly destroy the objects
associated to the task that are not to be used in the future by a new invocation
of the task or by other tasks who hold valid capabilities for the objects.
A status word present in exit_status
is stored inside the kernel and is passed to the first thread calling task_wait.
The task's descriptor structure is kept by the kernel until task_wait is
called. Creating a task and not waiting for its termination is not a good
policy, because the kernel may run out of task descriptors.
Return Values
On success, task_destroy returns 0
and the capability task is no longer valid.
On fail, task_destroy returns a negative
value indicating one of the following errors:
See Also
task_create,
task_status, task_self,
task_exit, task_wait