瀏覽代碼

Protect status update around calling the job callback

Samuel Thibault 11 年之前
父節點
當前提交
3795950735
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      src/core/errorcheck.c

+ 8 - 1
src/core/errorcheck.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
+ * Copyright (C) 2009, 2010, 2014  Université de Bordeaux 1
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -26,7 +26,14 @@ void _starpu_set_local_worker_status(enum _starpu_worker_status st)
 	 * thereforce outside a worker), for instance if we are executing the
 	 * callback function of a task with a "NULL" codelet. */
 	if (worker)
+	{
+		starpu_pthread_mutex_t *sched_mutex;
+		starpu_pthread_cond_t *sched_cond;
+		starpu_worker_get_sched_condition(worker->workerid, &sched_mutex, &sched_cond);
+		STARPU_PTHREAD_MUTEX_LOCK(mutex);
 		worker->status = st;
+		STARPU_PTHREAD_MUTEX_UNLOCK(mutex);
+	}
 }
 
 enum _starpu_worker_status _starpu_get_local_worker_status(void)