Use exponential backoff in mutexes

This commit is contained in:
Justine Tunney 2022-06-17 04:17:21 -07:00
parent a0ddb889da
commit 7b34f32fc4
2 changed files with 3 additions and 2 deletions

View file

@ -29,7 +29,8 @@
* @return 0 on success, or error number on failure
*/
int pthread_mutex_lock(pthread_mutex_t *mutex) {
int i, me, owner, tries;
volatile int i;
int me, owner, tries;
for (tries = 0, me = gettid();;) {
owner = atomic_load_explicit(&mutex->lock, memory_order_relaxed);
if (!owner && atomic_compare_exchange_weak_explicit(

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/macros.internal.inc"
.scall sys_sched_yield,0x15e12a14b103c018,globl,hidden
.scall sys_sched_yield,0x15e12a14bffff018,globl,hidden