spinlocks

This commit is contained in:
Matheus
2022-07-22 18:30:13 -03:00
parent 7590d01d91
commit 8f24f480b1
+12
View File
@@ -0,0 +1,12 @@
#ifndef _SPINLOCK_H_INCLUDE
#define _SPINLOCK_H_INCLUDE
static inline void spinlock_acquire(int *lock){
while(!__sync_bool_compare_and_swap(lock, 0, 1));
}
static inline void spinlock_release(int *lock){
*lock = 0;
}
#endif