Commit 19cfb535 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

use re-entrant random number generator.


Former-commit-id: 48f6a62012fbc2705cc16d6d7a896c21f9880036
parent bb4462a1
......@@ -1239,6 +1239,7 @@ void *runner_main ( void *data ) {
struct queue *queues[ r->nr_queues ], *myq;
struct task *t;
struct cell *ci, *cj;
unsigned int myseed = rand() + rt->id;
#ifdef TIMER
ticks stalled;
#endif
......@@ -1288,7 +1289,7 @@ void *runner_main ( void *data ) {
if ( ( myq->next == myq->count ) ||
( t = queue_gettask( myq , 0 , 0 ) ) == NULL ) {
TIMER_TIC2
qid = rand() % naq;
qid = rand_r( &myseed ) % naq;
keep = ( r->policy & runner_policy_keep ) &&
( myq->count <= myq->size-tpq );
if ( myq->next == myq->count )
......@@ -1312,7 +1313,7 @@ void *runner_main ( void *data ) {
}
}
else if ( r->policy & runner_policy_rand ) {
qid = rand() % naq;
qid = rand_r( &myseed ) % naq;
t = queue_gettask( queues[qid] , r->policy & runner_policy_block , 0 );
}
else {
......
Supports Markdown
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