Ejemplo n.º 1
0
/**
 * Schedules a running task for execution. Only running tasks can be
 * activated.  Blocked tasks have to be unblocked before they can be
 * activated.
 *
 * Returns NULL if no tasks can be scheduled.
 */
rust_task *
rust_sched_loop::schedule_task() {
    lock.must_have_lock();
    size_t tasks = running_tasks.length();
    if (tasks > 0) {
        size_t i = (tasks > 1) ? (rng_gen_u32(&rng) % tasks) : 0;
        return running_tasks[i];
    }
    return NULL;
}
Ejemplo n.º 2
0
extern "C" CDECL uint32_t
rand_next(rust_rng *rng) {
    return rng_gen_u32(rng);
}
Ejemplo n.º 3
0
extern "C" CDECL uint32_t
rand_next(rust_rng *rng) {
    rust_task *task = rust_get_current_task();
    return rng_gen_u32(task->kernel, rng);
}