Revert "Make spin locks go faster"

This reverts commit c8e25d811c.
This commit is contained in:
Justine Tunney 2024-07-25 22:24:32 -07:00
parent 0679cfeb41
commit 02e1cbcd00
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
16 changed files with 122 additions and 149 deletions

View file

@ -28,8 +28,9 @@
#include "third_party/nsync/futex.internal.h"
#include "third_party/nsync/mu.h"
static void pthread_mutex_unlock_spin(atomic_int *word) {
atomic_store_explicit(word, 0, memory_order_release);
static void pthread_mutex_unlock_naive(pthread_mutex_t *mutex, uint64_t word) {
uint64_t lock = MUTEX_UNLOCK(word);
atomic_store_explicit(&mutex->_word, lock, memory_order_release);
}
// see "take 3" algorithm in "futexes are tricky" by ulrich drepper
@ -101,7 +102,7 @@ errno_t pthread_mutex_unlock(pthread_mutex_t *mutex) {
if (_weaken(nsync_futex_wake_)) {
pthread_mutex_unlock_drepper(&mutex->_futex, MUTEX_PSHARED(word));
} else {
pthread_mutex_unlock_spin(&mutex->_futex);
pthread_mutex_unlock_naive(mutex, word);
}
return 0;
}