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:
Pawel Dziepak
2013-11-05 22:47:18 +01:00
parent 077c84eb27
commit 273f2f38cd
2 changed files with 14 additions and 12 deletions
+2 -2
View File
@@ -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);
}