A few things needed in the destroy code paths of a thread are added.

The first one is related to resource recycling. The parent which is waiting its
child to exit did not delete its ktcb. Now, it deletes.

The second one is related to self destroy. The added code wakes up all the
waiters before it exits.
This commit is contained in:
Bora Sahin
2009-11-17 21:20:09 +02:00
parent b2a2340594
commit 9a8e1fa437

View File

@@ -105,12 +105,18 @@ int thread_destroy_children(void)
void thread_destroy_self(unsigned int exit_code)
{
thread_destroy_children();
/* Wake up waiters */
wake_up_all(&current->wqh_send, WAKEUP_INTERRUPT);
wake_up_all(&current->wqh_recv, WAKEUP_INTERRUPT);
current->exit_code = exit_code;
sched_exit_sync();
}
int thread_wait(struct ktcb *task)
{
unsigned int exit_code;
int ret;
/* Wait until task switches to desired state */
@@ -118,8 +124,12 @@ int thread_wait(struct ktcb *task)
task->state == TASK_DEAD, ret);
if (ret < 0)
return ret;
else
return (int)task->exit_code;
else {
exit_code = (int)task->exit_code;
tcb_remove(task);
tcb_delete(task);
return exit_code;
}
}
int thread_destroy(struct ktcb *task, unsigned int exit_code)