Made root_task no longer special.

This commit is contained in:
Eric Holk 2011-07-23 14:01:43 -07:00
parent c15871ac51
commit b51f5c395c
8 changed files with 18 additions and 20 deletions

View file

@ -144,10 +144,11 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
rust_srv *srv = new rust_srv();
rust_kernel *kernel = new rust_kernel(srv);
kernel->start();
rust_scheduler *sched = kernel->get_scheduler();
rust_task *root_task = kernel->create_task(NULL, "main");
rust_scheduler *sched = root_task->sched;
command_line_args *args
= new (kernel, "main command line args")
command_line_args(sched->root_task, argc, argv);
command_line_args(root_task, argc, argv);
DLOG(sched, dom, "startup: %d args in 0x%" PRIxPTR,
args->argc, (uintptr_t)args->args);
@ -155,7 +156,7 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
DLOG(sched, dom, "startup: arg[%d] = '%s'", i, args->argv[i]);
}
sched->root_task->start(main_fn, (uintptr_t)args->args);
root_task->start(main_fn, (uintptr_t)args->args);
int num_threads = get_num_threads();

View file

@ -261,6 +261,11 @@ int rust_kernel::start_task_threads(int num_threads)
return sched->rval;
}
rust_task *
rust_kernel::create_task(rust_task *spawner, const char *name) {
return sched->create_task(spawner, name);
}
#ifdef __WIN32__
void
rust_kernel::win32_require(LPCTSTR fn, BOOL ok) {

View file

@ -121,6 +121,8 @@ public:
#ifdef __WIN32__
void win32_require(LPCTSTR fn, BOOL ok);
#endif
rust_task *create_task(rust_task *spawner, const char *name);
};
class rust_task_thread : public rust_thread {

View file

@ -16,8 +16,6 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel,
blocked_tasks(this, "blocked"),
dead_tasks(this, "dead"),
cache(this),
root_task(NULL),
curr_task(NULL),
rval(0),
kernel(kernel),
message_queue(message_queue)
@ -29,7 +27,6 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel,
pthread_attr_setstacksize(&attr, 1024 * 1024);
pthread_attr_setdetachstate(&attr, true);
#endif
root_task = create_task(NULL, name);
}
rust_scheduler::~rust_scheduler() {

View file

@ -46,8 +46,6 @@ struct rust_scheduler : public kernel_owned<rust_scheduler>,
rust_crate_cache cache;
randctx rctx;
rust_task *root_task;
rust_task *curr_task;
int rval;
rust_kernel *kernel;

View file

@ -103,8 +103,8 @@ rust_task::~rust_task()
/* FIXME: tighten this up, there are some more
assertions that hold at task-lifecycle events. */
I(sched, ref_count == 0 ||
(ref_count == 1 && this == sched->root_task));
// I(sched, ref_count == 0 ||
// (ref_count == 1 && this == sched->root_task));
del_stk(this, stk);
}
@ -207,8 +207,8 @@ rust_task::kill() {
// Unblock the task so it can unwind.
unblock();
if (this == sched->root_task)
sched->fail();
// if (this == sched->root_task)
// sched->fail();
LOG(this, task, "preparing to unwind task: 0x%" PRIxPTR, this);
// run_on_resume(rust_unwind_glue);
@ -229,8 +229,6 @@ rust_task::fail() {
supervisor->kill();
}
// FIXME: implement unwinding again.
if (this == sched->root_task)
sched->fail();
failed = true;
}

View file

@ -123,9 +123,6 @@ rust_task : public maybe_proxy<rust_task>,
void die();
void unblock();
void check_active() { I(sched, sched->curr_task == this); }
void check_suspended() { I(sched, sched->curr_task != this); }
// Print a backtrace, if the "bt" logging option is on.
void backtrace();

View file

@ -45,9 +45,9 @@ void task_entry() {
void
rust_task_test::worker::run() {
rust_scheduler *scheduler = kernel->get_scheduler();
scheduler->root_task->start((uintptr_t)&task_entry, (uintptr_t)NULL);
scheduler->start_main_loop(0);
rust_task *root_task = kernel->create_task(NULL, "main");
root_task->start((uintptr_t)&task_entry, (uintptr_t)NULL);
root_task->sched->start_main_loop(0);
}
bool