ソースを参照

barrier: fix return value
Upon completion, the pthread_barrier_wait() function returns
PTHREAD_BARRIER_SERIAL_THREAD for the thread which last reached the
barrier and zero for each of the other threads.

Nathalie Furmento 14 年 前
コミット
c7b098b766
共有2 個のファイルを変更した8 個の追加1 個の削除を含む
  1. 4 1
      src/common/barrier.c
  2. 4 0
      src/common/barrier.h

+ 4 - 1
src/common/barrier.c

@@ -34,17 +34,20 @@ int _starpu_barrier_destroy(_starpu_barrier_t *barrier)
 
 int _starpu_barrier_wait(_starpu_barrier_t *barrier)
 {
+	int ret=0;
+
 	pthread_mutex_lock(&barrier->mutex);
 	barrier->reached++;
 	if (barrier->reached == barrier->count)
 	{
 		barrier->reached = 0;
 		pthread_cond_broadcast(&barrier->cond);
+		ret = PTHREAD_BARRIER_SERIAL_THREAD;
 	}
 	else
 	{
 		pthread_cond_wait(&barrier->cond,&barrier->mutex);
 	}
 	pthread_mutex_unlock(&barrier->mutex);
-	return 0;
+	return ret;
 }

+ 4 - 0
src/common/barrier.h

@@ -17,6 +17,10 @@
 #ifndef __COMMON_BARRIER_H__
 #define __COMMON_BARRIER_H__
 
+#if defined(__CYGWIN__)
+# define PTHREAD_BARRIER_SERIAL_THREAD -1
+#endif
+
 typedef struct {
 	int count;
 	int reached;