From b51f5c395cc3458e428159b908ca95b1777e66e2 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Sat, 23 Jul 2011 14:01:43 -0700 Subject: [PATCH] Made root_task no longer special. --- src/rt/rust.cpp | 7 ++++--- src/rt/rust_kernel.cpp | 5 +++++ src/rt/rust_kernel.h | 2 ++ src/rt/rust_scheduler.cpp | 3 --- src/rt/rust_scheduler.h | 2 -- src/rt/rust_task.cpp | 10 ++++------ src/rt/rust_task.h | 3 --- src/rt/test/rust_test_runtime.cpp | 6 +++--- 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp index 029532363c8e..06097e341977 100644 --- a/src/rt/rust.cpp +++ b/src/rt/rust.cpp @@ -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(); diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index d15d52ba431c..53c2d945b09c 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -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) { diff --git a/src/rt/rust_kernel.h b/src/rt/rust_kernel.h index 6edb0f38dd5f..07f4ff2f7876 100644 --- a/src/rt/rust_kernel.h +++ b/src/rt/rust_kernel.h @@ -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 { diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp index 18ac66beb5ee..09a78cebddbc 100644 --- a/src/rt/rust_scheduler.cpp +++ b/src/rt/rust_scheduler.cpp @@ -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() { diff --git a/src/rt/rust_scheduler.h b/src/rt/rust_scheduler.h index b1b9d51db568..cabcdf210a89 100644 --- a/src/rt/rust_scheduler.h +++ b/src/rt/rust_scheduler.h @@ -46,8 +46,6 @@ struct rust_scheduler : public kernel_owned, rust_crate_cache cache; randctx rctx; - rust_task *root_task; - rust_task *curr_task; int rval; rust_kernel *kernel; diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index af55208582e6..de6b00acb3fd 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -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; } diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h index 13b5537d5d9b..b1984b9d40b8 100644 --- a/src/rt/rust_task.h +++ b/src/rt/rust_task.h @@ -123,9 +123,6 @@ rust_task : public maybe_proxy, 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(); diff --git a/src/rt/test/rust_test_runtime.cpp b/src/rt/test/rust_test_runtime.cpp index 8acfe45c9e65..f9a99d9acb1e 100644 --- a/src/rt/test/rust_test_runtime.cpp +++ b/src/rt/test/rust_test_runtime.cpp @@ -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