Skip to content
Snippets Groups Projects
Commit 23768ccc authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

change stealing policy.

Former-commit-id: 317f4e99a66d7be7da3d1d914d152bcd38a4c6fd
parent 4fc04613
No related branches found
No related tags found
No related merge requests found
......@@ -754,16 +754,12 @@ struct task *scheduler_gettask ( struct scheduler *s , int qid ) {
/* If unsucessful, try stealing from the other queues. */
if ( s->flags & scheduler_flag_steal ) {
int qids[ nr_queues ];
int count = 0, qids[ nr_queues ];
for ( k = 0 ; k < nr_queues ; k++ )
qids[k] = k;
for ( k = 0 ; k < nr_queues ; k++ ) {
int j = k + ( rand() % (nr_queues - k) );
int temp = qids[j];
qids[j] = qids[k];
if ( temp == qid )
continue;
if ( s->queues[temp].count > 0 && ( res = queue_gettask( &s->queues[temp] , qid , 0 ) ) != NULL )
if ( s->queues[k].count > 0 )
qids[ count++ ] = k;
if ( count > 1 ) {
if ( ( res = queue_gettask( &s->queues[ qids[ rand() % count ] ] , qid , 0 ) ) != NULL )
break;
}
}
......
......@@ -26,7 +26,7 @@
/* Flags . */
#define scheduler_flag_none 0
#define scheduler_flag_steal 1
#define scheduler_flag_maxsteal 1
#define scheduler_flag_maxsteal 10
/* Data of a scheduler. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment