Loading...
pthreads.subproj/pthread_internals.h Libc-186 Libc-166
--- Libc/Libc-186/pthreads.subproj/pthread_internals.h
+++ Libc/Libc-166/pthreads.subproj/pthread_internals.h
@@ -198,33 +198,24 @@
 
 /* Number of times to spin when the lock is unavailable and we are on a
    multiprocessor.  On a uniprocessor we yield the processor immediately.  */
-#define	MP_SPIN_TRIES	1000
+#define SPIN_TRIES 10
 extern int _spin_tries;
 extern int __is_threaded;
 extern int _cpu_has_altivec;
 
 /* Internal mutex locks for data structures */
-#define TRY_LOCK(v) (!__is_threaded || _spin_lock_try((pthread_lock_t *)&(v)))
-#define LOCK(v)																\
-do {																		\
-	if (__is_threaded) {													\
-		int		tries = _spin_tries;										\
-																			\
-		while (!_spin_lock_try((pthread_lock_t *)&(v))) {					\
-			if (tries-- > 0)												\
-				continue;													\
-																			\
-			syscall_thread_switch(THREAD_NULL, SWITCH_OPTION_DEPRESS, 1);	\
-			tries = _spin_tries;											\
-		}																	\
-	}																		\
-} while (0)
-#define UNLOCK(v)								\
-do {											\
-	if (__is_threaded)							\
-		_spin_unlock((pthread_lock_t *)&(v));	\
-} while (0)
-
+#define TRY_LOCK(v) (!__is_threaded || _spin_lock_try((pthread_lock_t *)&v))
+#if 0
+#define LOCK(v) if (__is_threaded) _spin_lock((pthread_lock_t)&v)
+#else
+#define LOCK(v) \
+        if (__is_threaded) { \
+		while (!_spin_lock_try((pthread_lock_t *)&v)) {	\
+		    syscall_thread_switch(THREAD_NULL, SWITCH_OPTION_WAIT, 1); \
+		} \
+	}
+#endif
+#define UNLOCK(v) if (__is_threaded) _spin_unlock((pthread_lock_t *)&v)
 #ifndef ESUCCESS
 #define ESUCCESS 0
 #endif