minor locking optimizations
[musl] / src / thread / __lock.c
1 #include "pthread_impl.h"
2
3 void __lock(volatile int *l)
4 {
5         int spins=10000;
6         /* Do not use futexes because we insist that unlocking is a simple
7          * assignment to optimize non-pathological code with no contention. */
8         while (a_xchg(l, 1))
9                 if (spins) spins--, a_spin();
10                 else __syscall(SYS_sched_yield);
11 }