diff options
Diffstat (limited to 'kernel.soso/spinlock.c')
-rw-r--r-- | kernel.soso/spinlock.c | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/kernel.soso/spinlock.c b/kernel.soso/spinlock.c deleted file mode 100644 index 8efbdb20..00000000 --- a/kernel.soso/spinlock.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "spinlock.h" - -static inline int32 exchangeAtomic(volatile int32* oldValueAddress, int32 newValue) { - //no need to use lock instruction on xchg - - asm volatile ("xchgl %0, %1" - : "=r"(newValue) - : "m"(*oldValueAddress), "0"(newValue) - : "memory"); - return newValue; -} - -void Spinlock_Init(Spinlock* spinlock) { - *spinlock = 0; -} - -void Spinlock_Lock(Spinlock* spinlock) { - while (exchangeAtomic((int32*)spinlock, 1)) { - halt(); - } -} - -void Spinlock_Unlock(Spinlock* spinlock) { - *spinlock = 0; -} |