Просмотр исходного кода

synchronous tasks may have finished before we start waiting

Cédric Augonnet лет назад: 16
Родитель
Сommit
cb1e83be1b
1 измененных файлов с 8 добавлено и 9 удалено
  1. 8 9
      src/core/jobs.c

+ 8 - 9
src/core/jobs.c

@@ -124,20 +124,19 @@ void handle_job_termination(job_t j)
 
 static void block_sync_task(job_t j)
 {
-	{
 #if defined(__APPLE__) && defined(__MACH__)
-		pthread_mutex_lock(&j->sync_mutex);
+	pthread_mutex_lock(&j->sync_mutex);
+	if (!j->terminated)
 		pthread_cond_wait(&j->sync_cond, &j->sync_mutex);
-		pthread_mutex_unlock(&j->sync_mutex);
+	pthread_mutex_unlock(&j->sync_mutex);
 #else
-		sem_wait(&j->sync_sem);
-		sem_destroy(&j->sync_sem);
+	sem_wait(&j->sync_sem);
+	sem_destroy(&j->sync_sem);
 #endif
 
-		/* as this is a synchronous task, the liberation of the job
-		   structure was deferred */
-		job_delete(j);
-	}
+	/* as this is a synchronous task, the liberation of the job
+	   structure was deferred */
+	job_delete(j);
 }
 
 /* application should submit new tasks to StarPU through this function */