Kaynağa Gözat

merge from trunk

Corentin Salingue 8 yıl önce
ebeveyn
işleme
4066fad231
2 değiştirilmiş dosya ile 14 ekleme ve 5 silme
  1. 12 4
      src/common/thread.c
  2. 2 1
      src/common/thread.h

+ 12 - 4
src/common/thread.c

@@ -829,11 +829,19 @@ void _starpu_pthread_spin_do_unlock(starpu_pthread_spinlock_t *lock)
 	 */
 	lock->taken = 0;
 	STARPU_SYNCHRONIZE();
-	if (syscall(SYS_futex, &lock->taken, _starpu_futex_wake, 1, NULL, NULL, 0))
-		if (errno == ENOSYS)
+	if (syscall(SYS_futex, &lock->taken, _starpu_futex_wake, 1, NULL, NULL, 0) == -1)
+		switch (errno)
 		{
-			_starpu_futex_wake = FUTEX_WAKE;
-			syscall(SYS_futex, &lock->taken, _starpu_futex_wake, 1, NULL, NULL, 0);
+			case ENOSYS:
+				_starpu_futex_wake = FUTEX_WAKE;
+				if (syscall(SYS_futex, &lock->taken, _starpu_futex_wake, 1, NULL, NULL, 0) == -1)
+					STARPU_ASSERT_MSG(0, "futex(wake) returned %d!", errno);
+				break;
+			case 0:
+				break;
+			default:
+				STARPU_ASSERT_MSG(0, "futex returned %d!", errno);
+				break;
 		}
 }
 

+ 2 - 1
src/common/thread.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2012-2014, 2016  Université de Bordeaux
+ * Copyright (C) 2010, 2012-2014, 2016-2017  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2016  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -116,6 +116,7 @@ static inline int _starpu_pthread_spin_unlock(starpu_pthread_spinlock_t *lock)
 	lock->taken = 0;
 #elif defined(STARPU_LINUX_SYS) && defined(STARPU_HAVE_XCHG)
 	STARPU_ASSERT(lock->taken != 0);
+	STARPU_SYNCHRONIZE();
 	unsigned next = STARPU_ATOMIC_ADD(&lock->taken, -1);
 	if (STARPU_LIKELY(next == 0))
 		/* Nobody to wake, we are done */