rt: Change the lifecycle of tasks and schedulers for various reasons

This is in preparation for giving schedulers their own life cycle separate
from the kernel.

Tasks must be deleted before their scheduler thread, so we can't let the
scheduler exit before all its tasks have been cleaned up. In this scheme,
the scheduler will unregister tasks with the kernel when they are reaped,
then drop their ref on the task (there may still be others). When the task
ref count hits zero, the task will request to be unregistered from the
scheduler, which is responsible for deleting the task.

Instead of having the kernel tell the scheduler to exit, let the scheduler
decide when to exit. For now it will exit when all of its tasks are
unregistered.
This commit is contained in:
Brian Anderson
2012-02-06 23:38:22 -08:00
parent ebc3646c39
commit 028af5cb6c
8 changed files with 66 additions and 23 deletions

View File

@@ -268,7 +268,8 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
}
}
rust_task::~rust_task()
void
rust_task::delete_this()
{
I(thread, !thread->lock.lock_held_by_current_thread());
I(thread, port_table.is_empty());
@@ -291,6 +292,8 @@ rust_task::~rust_task()
while (stk != NULL) {
del_stk(this, stk);
}
thread->release_task(this);
}
struct spawn_args {