source:
EcnlProtoTool/trunk/musl-1.1.18/src/thread/__wait.c@
444
Last change on this file since 444 was 444, checked in by , 4 years ago | |
---|---|
|
|
File size: 449 bytes |
Line | |
---|---|
1 | #include "pthread_impl.h" |
2 | |
3 | void __wait(volatile int *addr, volatile int *waiters, int val, int priv) |
4 | { |
5 | int spins=100; |
6 | if (priv) priv = FUTEX_PRIVATE; |
7 | while (spins-- && (!waiters || !*waiters)) { |
8 | if (*addr==val) a_spin(); |
9 | else return; |
10 | } |
11 | if (waiters) a_inc(waiters); |
12 | while (*addr==val) { |
13 | __syscall(SYS_futex, addr, FUTEX_WAIT|priv, val, 0) != -ENOSYS |
14 | || __syscall(SYS_futex, addr, FUTEX_WAIT, val, 0); |
15 | } |
16 | if (waiters) a_dec(waiters); |
17 | } |
Note:
See TracBrowser
for help on using the repository browser.