spinlock.h 234 B

1234567891011121314
  1. #pragma once
  2. #ifndef spin_lock
  3. static void spin_lock(int volatile * lock) {
  4. while(__sync_lock_test_and_set(lock, 0x01)) {
  5. syscall_yield();
  6. }
  7. }
  8. static void spin_unlock(int volatile * lock) {
  9. __sync_lock_release(lock);
  10. }
  11. #endif