(__pthread_lock): Top max_count value with MAX_ADAPTIVE_SPIN_COUNT.
authordrepper <drepper>
Thu, 30 Aug 2001 02:11:19 +0000 (02:11 +0000)
committerdrepper <drepper>
Thu, 30 Aug 2001 02:11:19 +0000 (02:11 +0000)
linuxthreads/spinlock.c

index 199386a..3e16825 100644 (file)
@@ -94,6 +94,9 @@ again:
   if (__pthread_smp_kernel) {
     int max_count = lock->__spinlock * 2 + 10;
 
+    if (max_count > MAX_ADAPTIVE_SPIN_COUNT)
+      max_count = MAX_ADAPTIVE_SPIN_COUNT;
+
     for (spin_count = 0; spin_count < max_count; spin_count++) {
       if (((oldstatus = lock->__status) & 1) == 0) {
        if(__compare_and_swap(&lock->__status, oldstatus, oldstatus | 1))
@@ -104,6 +107,9 @@ again:
          return;
        }
       }
+#ifdef BUSY_WAIT_NOP
+      BUSY_WAIT_NOP;
+#endif
       __asm __volatile ("" : "=m" (lock->__status) : "0" (lock->__status));
     }