diff options
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/x86/include/arch/smp/spinlock.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/arch/x86/include/arch/smp/spinlock.h b/src/arch/x86/include/arch/smp/spinlock.h index 799ac2c8b8..0c06c22bba 100644 --- a/src/arch/x86/include/arch/smp/spinlock.h +++ b/src/arch/x86/include/arch/smp/spinlock.h @@ -3,6 +3,8 @@ #ifndef ARCH_SMP_SPINLOCK_H #define ARCH_SMP_SPINLOCK_H +#include <thread.h> + /* * Your basic SMP spinlocks, allowing only a single CPU anywhere */ @@ -54,10 +56,16 @@ static __always_inline void spin_lock(spinlock_t *lock) __asm__ __volatile__( spin_lock_string : "=m" (lock->lock) : : "memory"); + + /* Switching contexts while holding a spinlock will lead to deadlocks */ + thread_coop_disable(); + } static __always_inline void spin_unlock(spinlock_t *lock) { + thread_coop_enable(); + __asm__ __volatile__( spin_unlock_string : "=m" (lock->lock) : : "memory"); |