Commit c2a3e1b9 authored by Aidan Chalk's avatar Aidan Chalk

Changed the use of rand to rand_r to hopefully improve performance and to be thread-safe

parent f9c431d4
......@@ -810,7 +810,8 @@ struct task *qsched_gettask ( struct qsched *s , int qid ) {
int naq, k, tid, qids[ s->nr_queues ];
struct task *t;
unsigned int seed = qid;
TIMER_TIC
/* Check if the sched is ok. */
......@@ -836,7 +837,7 @@ struct task *qsched_gettask ( struct qsched *s , int qid ) {
if ( k != qid && s->queues[k].count > 0 )
qids[ naq++ ] = k;
while ( naq > 0 ) {
k = rand() % naq;
k = rand_r(&seed) % naq;
TIMER_TIC2
tid = queue_get( &s->queues[ qids[k] ] , s , 0 );
TIMER_TOC( s , qsched_timer_queue )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment