瀏覽代碼

src/core/task.c: nanosleep does not exist on windows systems, use Sleep

Nathalie Furmento 12 年之前
父節點
當前提交
59f4d4d1af
共有 1 個文件被更改,包括 18 次插入4 次删除
  1. 18 4
      src/core/task.c

+ 18 - 4
src/core/task.c

@@ -33,6 +33,9 @@
 #include <core/debug.h>
 #include <core/sched_ctx.h>
 #include <time.h>
+#ifdef STARPU_HAVE_WINDOWS
+#include <windows.h>
+#endif
 
 /* XXX this should be reinitialized when StarPU is shutdown (or we should make
  * sure that no task remains !) */
@@ -1011,12 +1014,25 @@ char *_starpu_task_get_cpu_name_nth_implementation(struct starpu_codelet *cl, un
 	return cl->cpu_funcs_name[nimpl];
 }
 
+void _starpu_sleep(struct timespec ts)
+{
+#ifdef STARPU_HAVE_WINDOWS
+	Sleep((ts.tv_sec * 1000) + (ts.tv_nsec / 1000000));
+#else
+	struct timespec req, rem;
+
+	req = ts;
+	while (nanosleep(&req, &rem))
+		req = rem;
+#endif
+}
+
 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)
 {
-	struct timespec ts, req, rem;
+	struct timespec ts;
 	char *timeout_env;
 	unsigned long long timeout;
 
@@ -1034,9 +1050,7 @@ static void *watchdog_func(void *foo STARPU_ATTRIBUTE_UNUSED)
 		watchdog_ok = 0;
 		STARPU_PTHREAD_MUTEX_UNLOCK(&submitted_mutex);
 
-		req = ts;
-		while (nanosleep(&req, &rem))
-			req = rem;
+		_starpu_sleep(ts);
 
 		STARPU_PTHREAD_MUTEX_LOCK(&submitted_mutex);
 		if (!watchdog_ok && last_nsubmitted