rt: Do all task creation through a scheduler
This commit is contained in:
parent
bf250bec7c
commit
e7f00b6493
@ -1,5 +1,6 @@
|
||||
#include "rust_internal.h"
|
||||
#include "rust_util.h"
|
||||
#include "rust_scheduler.h"
|
||||
#include <cstdio>
|
||||
|
||||
struct
|
||||
@ -87,7 +88,8 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
||||
|
||||
rust_srv *srv = new rust_srv(env);
|
||||
rust_kernel *kernel = new rust_kernel(srv, env->num_sched_threads);
|
||||
rust_task_id root_id = kernel->create_task(NULL, "main", MAIN_STACK_SIZE);
|
||||
rust_scheduler *sched = kernel->get_default_scheduler();
|
||||
rust_task_id root_id = sched->create_task(NULL, "main", MAIN_STACK_SIZE);
|
||||
rust_task *root_task = kernel->get_task_by_id(root_id);
|
||||
I(kernel, root_task != NULL);
|
||||
rust_task_thread *thread = root_task->thread;
|
||||
|
@ -65,6 +65,11 @@ int rust_kernel::start_schedulers()
|
||||
return rval;
|
||||
}
|
||||
|
||||
rust_scheduler *
|
||||
rust_kernel::get_default_scheduler() {
|
||||
return sched;
|
||||
}
|
||||
|
||||
void
|
||||
rust_kernel::fail() {
|
||||
// FIXME: On windows we're getting "Application has requested the
|
||||
@ -77,17 +82,6 @@ rust_kernel::fail() {
|
||||
sched->kill_all_tasks();
|
||||
}
|
||||
|
||||
rust_task_id
|
||||
rust_kernel::create_task(rust_task *spawner, const char *name,
|
||||
size_t init_stack_sz) {
|
||||
return sched->create_task(spawner, name, init_stack_sz);
|
||||
}
|
||||
|
||||
rust_task_id
|
||||
rust_kernel::create_task(rust_task *spawner, const char *name) {
|
||||
return create_task(spawner, name, env->min_stack_size);
|
||||
}
|
||||
|
||||
void
|
||||
rust_kernel::register_task(rust_task *task) {
|
||||
scoped_lock with(_kernel_lock);
|
||||
|
@ -47,17 +47,16 @@ public:
|
||||
void fail();
|
||||
|
||||
int start_schedulers();
|
||||
rust_scheduler* get_default_scheduler();
|
||||
|
||||
#ifdef __WIN32__
|
||||
void win32_require(LPCTSTR fn, BOOL ok);
|
||||
#endif
|
||||
|
||||
rust_task_id create_task(rust_task *spawner, const char *name,
|
||||
size_t init_stack_size);
|
||||
rust_task_id create_task(rust_task * spawner, const char *name);
|
||||
void register_task(rust_task *task);
|
||||
rust_task *get_task_by_id(rust_task_id id);
|
||||
void release_task_id(rust_task_id tid);
|
||||
|
||||
void set_exit_status(int code);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user