From 21f353778d87da7cae6e03a1b6f953bce7c99b89 Mon Sep 17 00:00:00 2001 From: Matheus Date: Sat, 23 Jul 2022 00:13:01 -0300 Subject: [PATCH] spinlock change add a pause instruction in order to not completely demolish the system bus in a lock --- src/include/kernel/spinlock.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/include/kernel/spinlock.h b/src/include/kernel/spinlock.h index a6e88ff5..e8088030 100644 --- a/src/include/kernel/spinlock.h +++ b/src/include/kernel/spinlock.h @@ -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){