spinlock change

add a pause instruction in order to not completely demolish the system bus in a lock
This commit is contained in:
Matheus
2022-07-23 00:13:01 -03:00
parent 33adf7036b
commit 21f353778d
+3 -1
View File
@@ -1,8 +1,10 @@
#ifndef _SPINLOCK_H_INCLUDE
#define _SPINLOCK_H_INCLUDE
// TODO rewrite this in a more arch independent way
static inline void spinlock_acquire(int *lock){
while(!__sync_bool_compare_and_swap(lock, 0, 1));
while(!__sync_bool_compare_and_swap(lock, 0, 1)) asm("pause");
}
static inline void spinlock_release(int *lock){