Example #1
0
// Only run this on the rust stack
MUST_CHECK bool rust_task::yield() {
    bool killed = false;

    if (disallow_yield > 0) {
        call_on_c_stack(this, (void *)rust_task_yield_fail);
    }

    // This check is largely superfluous; it's the one after the context swap
    // that really matters. This one allows us to assert a useful invariant.

    // NB: This takes lifecycle_lock three times, and I believe that none of
    // them are actually necessary, as per #3213. Removing the locks here may
    // cause *harmless* races with a killer... but I didn't observe any
    // substantial performance improvement from removing them, even with
    // msgsend-ring-pipes, and also it's my last day, so I'm not about to
    // remove them.  -- bblum
    if (must_fail_from_being_killed()) {
        {
            scoped_lock with(lifecycle_lock);
            assert(!(state == task_state_blocked));
        }
        killed = true;
    }

    // Return to the scheduler.
    ctx.next->swap(ctx);

    if (must_fail_from_being_killed()) {
        killed = true;
    }
    return killed;
}
Example #2
0
// Only run this on the rust stack
void
rust_task::yield(bool *killed) {
    if (must_fail_from_being_killed()) {
        I(thread, !blocked());
        *killed = true;
    }

    // Return to the scheduler.
    ctx.next->swap(ctx);

    if (must_fail_from_being_killed()) {
        *killed = true;
    }
}