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

re-define queue blocking param.

Former-commit-id: 3d8bc9a2652a01e3587a4d2439758dd758774ff8
parent 7d80a4c5
Branches
Tags
No related merge requests found
......@@ -144,8 +144,14 @@ struct task *queue_gettask ( struct queue *q , int qid , struct cell *super , in
while ( q->count > 0 ) {
/* Grab the task lock. */
if ( lock_lock( qlock ) != 0 )
error( "Locking the qlock failed.\n" );
if ( blocking ) {
if ( lock_lock( qlock ) != 0 )
error( "Locking the qlock failed.\n" );
}
else {
if ( lock_trylock( qlock ) != 0 )
return NULL;
}
/* Set some pointers we will use often. */
qtid = q->tid;
......@@ -221,7 +227,7 @@ struct task *queue_gettask ( struct queue *q , int qid , struct cell *super , in
error( "Unlocking the qlock failed.\n" );
/* Leave? */
if ( res != NULL || !blocking )
if ( res != NULL )
break;
} /* while there are tasks. */
......
......@@ -850,7 +850,7 @@ struct task *scheduler_gettask ( struct scheduler *s , int qid , struct cell *su
for ( int tries = 0 ; res == NULL && s->waiting && tries < scheduler_maxtries ; tries++ ) {
/* Try to get a task from the suggested queue. */
if ( ( res = queue_gettask( &s->queues[qid] , qid , super , 0 ) ) != NULL )
if ( s->queues[qid].count > 0 && ( res = queue_gettask( &s->queues[qid] , qid , super , 1 ) ) != NULL )
break;
/* If unsucessful, try stealing from the other queues. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment