rt: Make the initial segment of the main task's stack 1MB
This is a trick to fool microbenchmarks. Closes #1681
This commit is contained in:
parent
361f90e618
commit
6548cdd59b
@ -75,6 +75,8 @@ command_line_args : public kernel_owned<command_line_args>
|
||||
|
||||
int check_claims = 0;
|
||||
|
||||
const size_t MAIN_STACK_SIZE = 1024*1024;
|
||||
|
||||
extern "C" CDECL int
|
||||
rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
||||
|
||||
@ -85,7 +87,7 @@ 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");
|
||||
rust_task_id root_id = kernel->create_task(NULL, "main", MAIN_STACK_SIZE);
|
||||
rust_task *root_task = kernel->get_task_by_id(root_id);
|
||||
I(kernel, root_task != NULL);
|
||||
rust_scheduler *sched = root_task->sched;
|
||||
|
@ -151,15 +151,21 @@ rust_kernel::fail() {
|
||||
}
|
||||
|
||||
rust_task_id
|
||||
rust_kernel::create_task(rust_task *spawner, const char *name) {
|
||||
rust_kernel::create_task(rust_task *spawner, const char *name,
|
||||
size_t init_stack_sz) {
|
||||
scoped_lock with(_kernel_lock);
|
||||
rust_scheduler *thread = threads[isaac_rand(&rctx) % num_threads];
|
||||
rust_task *t = thread->create_task(spawner, name);
|
||||
rust_task *t = thread->create_task(spawner, name, init_stack_sz);
|
||||
t->user.id = max_id++;
|
||||
task_table.put(t->user.id, t);
|
||||
return t->user.id;
|
||||
}
|
||||
|
||||
rust_task_id
|
||||
rust_kernel::create_task(rust_task *spawner, const char *name) {
|
||||
return create_task(spawner, name, env->min_stack_size);
|
||||
}
|
||||
|
||||
rust_task *
|
||||
rust_kernel::get_task_by_id(rust_task_id id) {
|
||||
scoped_lock with(_kernel_lock);
|
||||
|
@ -66,7 +66,9 @@ public:
|
||||
void win32_require(LPCTSTR fn, BOOL ok);
|
||||
#endif
|
||||
|
||||
rust_task_id create_task(rust_task *spawner, const char *name);
|
||||
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);
|
||||
rust_task *get_task_by_id(rust_task_id id);
|
||||
void release_task_id(rust_task_id tid);
|
||||
void set_exit_status(int code);
|
||||
|
@ -333,10 +333,11 @@ rust_scheduler::get_cache() {
|
||||
}
|
||||
|
||||
rust_task *
|
||||
rust_scheduler::create_task(rust_task *spawner, const char *name) {
|
||||
rust_scheduler::create_task(rust_task *spawner, const char *name,
|
||||
size_t init_stack_sz) {
|
||||
rust_task *task =
|
||||
new (this->kernel, "rust_task")
|
||||
rust_task (this, &newborn_tasks, spawner, name);
|
||||
rust_task (this, &newborn_tasks, spawner, name, init_stack_sz);
|
||||
DLOG(this, task, "created task: " PTR ", spawner: %s, name: %s",
|
||||
task, spawner ? spawner->name : "null", name);
|
||||
if(spawner) {
|
||||
|
@ -112,7 +112,8 @@ struct rust_scheduler : public kernel_owned<rust_scheduler>,
|
||||
|
||||
void kill_all_tasks();
|
||||
|
||||
rust_task *create_task(rust_task *spawner, const char *name);
|
||||
rust_task *create_task(rust_task *spawner, const char *name,
|
||||
size_t init_stack_sz);
|
||||
|
||||
virtual void run();
|
||||
|
||||
|
@ -239,7 +239,8 @@ del_stk(rust_task *task, stk_seg *stk)
|
||||
|
||||
// Tasks
|
||||
rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
|
||||
rust_task *spawner, const char *name) :
|
||||
rust_task *spawner, const char *name,
|
||||
size_t init_stack_sz) :
|
||||
ref_count(1),
|
||||
stk(NULL),
|
||||
runtime_sp(0),
|
||||
@ -271,7 +272,7 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
|
||||
|
||||
user.notify_enabled = 0;
|
||||
|
||||
stk = new_stk(sched, this, 0);
|
||||
stk = new_stk(sched, this, init_stack_sz);
|
||||
user.rust_sp = stk->end;
|
||||
if (supervisor) {
|
||||
supervisor->ref();
|
||||
|
@ -133,7 +133,8 @@ rust_task : public kernel_owned<rust_task>, rust_cond
|
||||
rust_task(rust_scheduler *sched,
|
||||
rust_task_list *state,
|
||||
rust_task *spawner,
|
||||
const char *name);
|
||||
const char *name,
|
||||
size_t init_stack_sz);
|
||||
|
||||
~rust_task();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user