mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 19:03:15 +01:00
Added different paths of exiting for pager and its children.
Created a task_dead list on pager for children to move to when they exit.
This commit is contained in:
@@ -183,23 +183,32 @@ void thread_destroy_current(void)
|
||||
{
|
||||
struct ktcb *task, *n;
|
||||
|
||||
/* Suspend all threads under control of this pager */
|
||||
spin_lock(&curcont->ktcb_list.list_lock);
|
||||
/* Signal death to all threads under control of this pager */
|
||||
mutex_lock(&curcont->ktcb_list.list_lock);
|
||||
list_foreach_removable_struct(task, n,
|
||||
&curcont->ktcb_list.list,
|
||||
task_list) {
|
||||
if (task->tid == current->tid ||
|
||||
task->pagerid != current->tid)
|
||||
continue;
|
||||
spin_unlock(&curcont->ktcb_list.list_lock);
|
||||
mutex_unlock(&curcont->ktcb_list.list_lock);
|
||||
|
||||
/* Here we wait for each to die */
|
||||
thread_suspend(task, TASK_EXITING);
|
||||
spin_lock(&curcont->ktcb_list.list_lock);
|
||||
mutex_lock(&curcont->ktcb_list.list_lock);
|
||||
}
|
||||
spin_unlock(&curcont->ktcb_list.list_lock);
|
||||
mutex_unlock(&curcont->ktcb_list.list_lock);
|
||||
|
||||
/* Indicate we want to become zombie on suspend */
|
||||
current->flags |= TASK_EXITING;
|
||||
/* Destroy all children */
|
||||
mutex_lock(¤t->task_dead.list_lock);
|
||||
list_foreach_removable_struct(task, n,
|
||||
¤t->task_dead.list,
|
||||
task_list) {
|
||||
tcb_delete(task);
|
||||
}
|
||||
mutex_unlock(¤t->task_dead.list_lock);
|
||||
|
||||
/* Destroy self */
|
||||
sched_die_sync();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user