X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fthread%2F__lock.c;h=2f345ae7af02153c1bffbd5cbfc0f0be860127a6;hp=d1717956a6f96f3ec1b0bb490350aab0dad4cf13;hb=HEAD;hpb=813d37839b97960d38f10ea93d9c4a391c1c91a5 diff --git a/src/thread/__lock.c b/src/thread/__lock.c index d1717956..2f345ae7 100644 --- a/src/thread/__lock.c +++ b/src/thread/__lock.c @@ -2,10 +2,11 @@ void __lock(volatile int *l) { - int spins=10000; - /* Do not use futexes because we insist that unlocking is a simple - * assignment to optimize non-pathological code with no contention. */ - while (a_swap(l, 1)) - if (spins) spins--, a_spin(); - else __syscall(SYS_sched_yield); + while (a_swap(l, 1)) __wait(l, l+1, 1, 1); +} + +void __unlock(volatile int *l) +{ + a_store(l, 0); + if (l[1]) __wake(l, 1, 1); }