kernel: Improve spinlock implementation
atomic_or() and atomic_and() are not supported by x86 are need to be emulated using CAS. Use atomic_get_and_set() and atomic_set() instead.
This commit is contained in:
@@ -76,7 +76,7 @@ int smp_intercpu_int_handler(int32 cpu);
|
||||
static inline bool
|
||||
try_acquire_spinlock_inline(spinlock* lock)
|
||||
{
|
||||
return atomic_or((int32*)lock, 1) == 0;
|
||||
return atomic_get_and_set((int32*)lock, 1) == 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ acquire_spinlock_inline(spinlock* lock)
|
||||
static inline void
|
||||
release_spinlock_inline(spinlock* lock)
|
||||
{
|
||||
atomic_and((int32*)lock, 0);
|
||||
atomic_set((int32*)lock, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user