Made root_task no longer special.
This commit is contained in:
@@ -144,10 +144,11 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
|||||||
rust_srv *srv = new rust_srv();
|
rust_srv *srv = new rust_srv();
|
||||||
rust_kernel *kernel = new rust_kernel(srv);
|
rust_kernel *kernel = new rust_kernel(srv);
|
||||||
kernel->start();
|
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
|
command_line_args *args
|
||||||
= new (kernel, "main command line 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,
|
DLOG(sched, dom, "startup: %d args in 0x%" PRIxPTR,
|
||||||
args->argc, (uintptr_t)args->args);
|
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]);
|
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();
|
int num_threads = get_num_threads();
|
||||||
|
|
||||||
|
|||||||
@@ -261,6 +261,11 @@ int rust_kernel::start_task_threads(int num_threads)
|
|||||||
return sched->rval;
|
return sched->rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rust_task *
|
||||||
|
rust_kernel::create_task(rust_task *spawner, const char *name) {
|
||||||
|
return sched->create_task(spawner, name);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
void
|
void
|
||||||
rust_kernel::win32_require(LPCTSTR fn, BOOL ok) {
|
rust_kernel::win32_require(LPCTSTR fn, BOOL ok) {
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ public:
|
|||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
void win32_require(LPCTSTR fn, BOOL ok);
|
void win32_require(LPCTSTR fn, BOOL ok);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
rust_task *create_task(rust_task *spawner, const char *name);
|
||||||
};
|
};
|
||||||
|
|
||||||
class rust_task_thread : public rust_thread {
|
class rust_task_thread : public rust_thread {
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel,
|
|||||||
blocked_tasks(this, "blocked"),
|
blocked_tasks(this, "blocked"),
|
||||||
dead_tasks(this, "dead"),
|
dead_tasks(this, "dead"),
|
||||||
cache(this),
|
cache(this),
|
||||||
root_task(NULL),
|
|
||||||
curr_task(NULL),
|
|
||||||
rval(0),
|
rval(0),
|
||||||
kernel(kernel),
|
kernel(kernel),
|
||||||
message_queue(message_queue)
|
message_queue(message_queue)
|
||||||
@@ -29,7 +27,6 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel,
|
|||||||
pthread_attr_setstacksize(&attr, 1024 * 1024);
|
pthread_attr_setstacksize(&attr, 1024 * 1024);
|
||||||
pthread_attr_setdetachstate(&attr, true);
|
pthread_attr_setdetachstate(&attr, true);
|
||||||
#endif
|
#endif
|
||||||
root_task = create_task(NULL, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rust_scheduler::~rust_scheduler() {
|
rust_scheduler::~rust_scheduler() {
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ struct rust_scheduler : public kernel_owned<rust_scheduler>,
|
|||||||
rust_crate_cache cache;
|
rust_crate_cache cache;
|
||||||
|
|
||||||
randctx rctx;
|
randctx rctx;
|
||||||
rust_task *root_task;
|
|
||||||
rust_task *curr_task;
|
|
||||||
int rval;
|
int rval;
|
||||||
|
|
||||||
rust_kernel *kernel;
|
rust_kernel *kernel;
|
||||||
|
|||||||
@@ -103,8 +103,8 @@ rust_task::~rust_task()
|
|||||||
|
|
||||||
/* FIXME: tighten this up, there are some more
|
/* FIXME: tighten this up, there are some more
|
||||||
assertions that hold at task-lifecycle events. */
|
assertions that hold at task-lifecycle events. */
|
||||||
I(sched, ref_count == 0 ||
|
// I(sched, ref_count == 0 ||
|
||||||
(ref_count == 1 && this == sched->root_task));
|
// (ref_count == 1 && this == sched->root_task));
|
||||||
|
|
||||||
del_stk(this, stk);
|
del_stk(this, stk);
|
||||||
}
|
}
|
||||||
@@ -207,8 +207,8 @@ rust_task::kill() {
|
|||||||
// Unblock the task so it can unwind.
|
// Unblock the task so it can unwind.
|
||||||
unblock();
|
unblock();
|
||||||
|
|
||||||
if (this == sched->root_task)
|
// if (this == sched->root_task)
|
||||||
sched->fail();
|
// sched->fail();
|
||||||
|
|
||||||
LOG(this, task, "preparing to unwind task: 0x%" PRIxPTR, this);
|
LOG(this, task, "preparing to unwind task: 0x%" PRIxPTR, this);
|
||||||
// run_on_resume(rust_unwind_glue);
|
// run_on_resume(rust_unwind_glue);
|
||||||
@@ -229,8 +229,6 @@ rust_task::fail() {
|
|||||||
supervisor->kill();
|
supervisor->kill();
|
||||||
}
|
}
|
||||||
// FIXME: implement unwinding again.
|
// FIXME: implement unwinding again.
|
||||||
if (this == sched->root_task)
|
|
||||||
sched->fail();
|
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,9 +123,6 @@ rust_task : public maybe_proxy<rust_task>,
|
|||||||
void die();
|
void die();
|
||||||
void unblock();
|
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.
|
// Print a backtrace, if the "bt" logging option is on.
|
||||||
void backtrace();
|
void backtrace();
|
||||||
|
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ void task_entry() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
rust_task_test::worker::run() {
|
rust_task_test::worker::run() {
|
||||||
rust_scheduler *scheduler = kernel->get_scheduler();
|
rust_task *root_task = kernel->create_task(NULL, "main");
|
||||||
scheduler->root_task->start((uintptr_t)&task_entry, (uintptr_t)NULL);
|
root_task->start((uintptr_t)&task_entry, (uintptr_t)NULL);
|
||||||
scheduler->start_main_loop(0);
|
root_task->sched->start_main_loop(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
Reference in New Issue
Block a user