Skip to content
Snippets Groups Projects

Use getticks() to get enough randomness when enqueing tasks without owners.

Merged Matthieu Schaller requested to merge rand_fix2 into master
+ 2
3
Compare changes
  • Side-by-side
  • Inline
+ 2
3
@@ -1381,9 +1381,8 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
if (qid >= s->nr_queues) error("Bad computed qid.");
/* If no previous owner, pick a random queue. */
if (qid < 0)
qid = rand_r((unsigned int *)pthread_getspecific(s->local_seed_pointer)) %
s->nr_queues;
/* Note that getticks() is random enough */
if (qid < 0) qid = getticks() % s->nr_queues;
/* Increase the waiting counter. */
atomic_inc(&s->waiting);
Loading