diff options
Diffstat (limited to 'kernel.soso/spinlock.c')
-rw-r--r-- | kernel.soso/spinlock.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/kernel.soso/spinlock.c b/kernel.soso/spinlock.c index 1ef2be13..8efbdb20 100644 --- a/kernel.soso/spinlock.c +++ b/kernel.soso/spinlock.c @@ -1,7 +1,6 @@ #include "spinlock.h" -static inline int32 exchangeAtomic(volatile int32* oldValueAddress, int32 newValue) -{ +static inline int32 exchangeAtomic(volatile int32* oldValueAddress, int32 newValue) { //no need to use lock instruction on xchg asm volatile ("xchgl %0, %1" @@ -11,20 +10,16 @@ static inline int32 exchangeAtomic(volatile int32* oldValueAddress, int32 newVal return newValue; } -void Spinlock_Init(Spinlock* spinlock) -{ +void Spinlock_Init(Spinlock* spinlock) { *spinlock = 0; } -void Spinlock_Lock(Spinlock* spinlock) -{ - while (exchangeAtomic((int32*)spinlock, 1)) - { +void Spinlock_Lock(Spinlock* spinlock) { + while (exchangeAtomic((int32*)spinlock, 1)) { halt(); } } -void Spinlock_Unlock(Spinlock* spinlock) -{ +void Spinlock_Unlock(Spinlock* spinlock) { *spinlock = 0; } |