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

try several steals after a failed get attempt on the preferred queue.

Former-commit-id: d0abb3e20eb09afe730495ce622866b8b8cf3fc2
parent 3babf1ea
Branches
Tags
No related merge requests found
......@@ -847,7 +847,7 @@ struct task *scheduler_gettask ( struct scheduler *s , int qid , struct cell *su
while ( s->waiting > 0 && res == NULL ) {
/* Try more than once before sleeping. */
for ( int tries = 0 ; res == NULL && tries < scheduler_flag_maxsteal ; tries++ ) {
for ( int tries = 0 ; res == NULL && tries < scheduler_maxtries ; tries++ ) {
/* Try to get a task from the suggested queue. */
if ( ( res = queue_gettask( &s->queues[qid] , qid , super , 0 ) ) != NULL )
......@@ -859,7 +859,14 @@ struct task *scheduler_gettask ( struct scheduler *s , int qid , struct cell *su
for ( k = 0 ; k < nr_queues ; k++ )
if ( s->queues[k].count > 0 )
qids[ count++ ] = k;
if ( count > 0 && ( res = queue_gettask( &s->queues[ qids[ rand() % count ] ] , qid , super , 0 ) ) != NULL )
for ( k = 0 ; k < scheduler_maxsteal && count > 0 ; k++ ) {
int ind = rand() % count;
if ( ( res = queue_gettask( &s->queues[ qids[ ind ] ] , qid , super , 0 ) ) != NULL )
break;
else
qids[ ind ] = qids[ --count ];
}
if ( res != NULL )
break;
}
......
......@@ -22,11 +22,12 @@
#define scheduler_maxwait 3
#define scheduler_maxunlock 40
#define scheduler_dosub 1
#define scheduler_maxsteal 10
#define scheduler_maxtries 10
/* Flags . */
#define scheduler_flag_none 0
#define scheduler_flag_steal 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