rt: Don't allocate a C stack for tasks that already have one

This commit is contained in:
Brian Anderson 2012-02-14 11:58:27 -08:00
parent 44d4889bc2
commit a53a08e1b9
3 changed files with 5 additions and 4 deletions

View file

@ -205,6 +205,7 @@ public:
void call_on_c_stack(void *args, void *fn_ptr);
void call_on_rust_stack(void *args, void *fn_ptr);
bool have_c_stack() { return c_stack != NULL; }
};
// This stuff is on the stack-switching fast path

View file

@ -70,7 +70,7 @@ rust_task_thread::activate(rust_task *task) {
task->ctx.next = &c_context;
DLOG(this, task, "descheduling...");
lock.unlock();
prepare_c_stack();
prepare_c_stack(task);
task->ctx.swap(c_context);
unprepare_c_stack();
lock.lock();
@ -367,9 +367,9 @@ rust_task_thread::exit() {
// stack), because once we're on the Rust stack we won't have enough
// room to do the allocation
void
rust_task_thread::prepare_c_stack() {
rust_task_thread::prepare_c_stack(rust_task *task) {
I(this, !extra_c_stack);
if (!cached_c_stack) {
if (!cached_c_stack && !task->have_c_stack()) {
cached_c_stack = create_stack(kernel, C_STACK_SIZE);
prepare_valgrind_stack(cached_c_stack);
}

View file

@ -98,7 +98,7 @@ private:
stk_seg *cached_c_stack;
stk_seg *extra_c_stack;
void prepare_c_stack();
void prepare_c_stack(rust_task *task);
void unprepare_c_stack();
public: