Browse Source

Do not even create the watchdog thread when STARPU_WATCHDOG_TIMEOUT is not set

Samuel Thibault 10 years ago
parent
commit
117254cf3b
1 changed files with 8 additions and 6 deletions
  1. 8 6
      src/core/task.c

+ 8 - 6
src/core/task.c

@@ -1116,15 +1116,12 @@ unsigned starpu_task_get_implementation(struct starpu_task *task)
 static starpu_pthread_t watchdog_thread;
 
 /* Check from times to times that StarPU does finish some tasks */
-static void *watchdog_func(void *foo STARPU_ATTRIBUTE_UNUSED)
+static void *watchdog_func(void *arg)
 {
 	struct timespec ts;
-	char *timeout_env;
+	char *timeout_env = arg;
 	unsigned long long timeout;
 
-	if (! (timeout_env = getenv("STARPU_WATCHDOG_TIMEOUT")))
-		return NULL;
-
 #ifdef _MSC_VER
 	timeout = (unsigned long long) _atoi64(timeout_env);
 #else
@@ -1166,8 +1163,13 @@ static void *watchdog_func(void *foo STARPU_ATTRIBUTE_UNUSED)
 void _starpu_watchdog_init(void)
 {
 	struct _starpu_machine_config *config = (struct _starpu_machine_config *)_starpu_get_machine_config();
+	char *timeout_env = getenv("STARPU_WATCHDOG_TIMEOUT");
+
+	if (!timeout_env)
+		return;
+
 	STARPU_PTHREAD_MUTEX_INIT(&config->submitted_mutex, NULL);
-	STARPU_PTHREAD_CREATE(&watchdog_thread, NULL, watchdog_func, NULL);
+	STARPU_PTHREAD_CREATE(&watchdog_thread, NULL, watchdog_func, timeout_env);
 }
 
 void _starpu_watchdog_shutdown(void)