1
0

__lock.c 230 B

123456789101112131415
  1. #include "pthread_impl.h"
  2. void __lock(volatile int *l)
  3. {
  4. if (libc.threads_minus_1)
  5. while (a_swap(l, 1)) __wait(l, l+1, 1, 1);
  6. }
  7. void __unlock(volatile int *l)
  8. {
  9. if (l[0]) {
  10. a_store(l, 0);
  11. if (l[1]) __wake(l, 1, 1);
  12. }
  13. }