summaryrefslogtreecommitdiff
path: root/libpthread/linuxthreads/spinlock.c
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2015-02-14 23:04:02 -0600
committerWaldemar Brodkorb <wbx@openadk.org>2015-02-14 23:04:02 -0600
commite1e46622ac0fce73d802fa4a8a2e83cc25cd9e7a (patch)
tree2c8d14e4dcc733f4227f0984ed05da5826b13acd /libpthread/linuxthreads/spinlock.c
parent6b6ede3d15f04fe825cfa9f697507457e3640344 (diff)
Revert "resolve merge"
This reverts commit 6b6ede3d15f04fe825cfa9f697507457e3640344.
Diffstat (limited to 'libpthread/linuxthreads/spinlock.c')
-rw-r--r--libpthread/linuxthreads/spinlock.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/libpthread/linuxthreads/spinlock.c b/libpthread/linuxthreads/spinlock.c
index 80aeda529..f0cf19c54 100644
--- a/libpthread/linuxthreads/spinlock.c
+++ b/libpthread/linuxthreads/spinlock.c
@@ -24,8 +24,6 @@
#include "spinlock.h"
#include "restart.h"
-libpthread_hidden_proto(nanosleep)
-
static void __pthread_acquire(int * spinlock);
static __inline__ void __pthread_release(int * spinlock)
@@ -65,6 +63,7 @@ void internal_function __pthread_lock(struct _pthread_fastlock * lock,
#if defined HAS_COMPARE_AND_SWAP
long oldstatus, newstatus;
int successful_seizure, spurious_wakeup_count;
+ int spin_count;
#endif
#if defined TEST_FOR_COMPARE_AND_SWAP
@@ -84,11 +83,11 @@ void internal_function __pthread_lock(struct _pthread_fastlock * lock,
return;
spurious_wakeup_count = 0;
+ spin_count = 0;
/* On SMP, try spinning to get the lock. */
-#if 0
+
if (__pthread_smp_kernel) {
- int spin_count;
int max_count = lock->__spinlock * 2 + 10;
if (max_count > MAX_ADAPTIVE_SPIN_COUNT)
@@ -112,7 +111,6 @@ void internal_function __pthread_lock(struct _pthread_fastlock * lock,
lock->__spinlock += (spin_count - lock->__spinlock) / 8;
}
-#endif
again:
@@ -617,6 +615,8 @@ void __pthread_alt_unlock(struct _pthread_fastlock *lock)
if (maxprio == INT_MIN)
continue;
+ ASSERT (p_max_prio != (struct wait_node *) 1);
+
/* Now we want to to remove the max priority thread's wait node from
the list. Before we can do this, we must atomically try to change the
node's abandon state from zero to nonzero. If we succeed, that means we
@@ -637,8 +637,20 @@ void __pthread_alt_unlock(struct _pthread_fastlock *lock)
#if defined HAS_COMPARE_AND_SWAP
wait_node_dequeue(pp_head, pp_max_prio, p_max_prio);
#endif
+
+ /* Release the spinlock *before* restarting. */
+#if defined TEST_FOR_COMPARE_AND_SWAP
+ if (!__pthread_has_cas)
+#endif
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+ {
+ __pthread_release(&lock->__spinlock);
+ }
+#endif
+
restart(p_max_prio->thr);
- break;
+
+ return;
}
}