Skip to content

Commit

Permalink
don't deplete RNG entropy when there is only one runnable task
Browse files Browse the repository at this point in the history
  • Loading branch information
cpeterso committed Feb 15, 2013
1 parent 9a78dc9 commit 9a76d71
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/rt/rust_sched_loop.cpp
Expand Up @@ -150,10 +150,10 @@ rust_sched_loop::release_task(rust_task *task) {
rust_task *
rust_sched_loop::schedule_task() {
lock.must_have_lock();
if (running_tasks.length() > 0) {
size_t k = rng_gen_u32(kernel, &rng);
size_t i = k % running_tasks.length();
return (rust_task *)running_tasks[i];
size_t tasks = running_tasks.length();
if (tasks > 0) {
size_t i = (tasks > 1) ? (rng_gen_u32(kernel, &rng) % tasks) : 0;
return running_tasks[i];
}
return NULL;
}
Expand Down

5 comments on commit 9a76d71

@bors
Copy link
Contributor

@bors bors commented on 9a76d71 Feb 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 9a76d71 Feb 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging cpeterso/rust/reseed-rng = 9a76d71 into auto

@bors
Copy link
Contributor

@bors bors commented on 9a76d71 Feb 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpeterso/rust/reseed-rng = 9a76d71 merged ok, testing candidate = 0a1fcad

@bors
Copy link
Contributor

@bors bors commented on 9a76d71 Feb 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 9a76d71 Feb 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 0a1fcad

Please sign in to comment.