use test-and-test-and-set lock
authorAndrew Waterman <waterman@eecs.berkeley.edu>
Fri, 14 Dec 2012 23:59:56 +0000 (15:59 -0800)
committerAndrew Waterman <waterman@eecs.berkeley.edu>
Sat, 15 Dec 2012 03:36:36 +0000 (19:36 -0800)
kern/arch/riscv/atomic.h

index f4b5d9d..ba0f2d0 100644 (file)
@@ -114,8 +114,11 @@ static inline uint32_t spin_trylock(spinlock_t* lock)
 
 static inline void spin_lock(spinlock_t *lock)
 {
-       while(spin_trylock(lock))
-               while(lock->rlock);
+       do
+       {
+               while (lock->rlock)
+                       ;
+       } while (spin_trylock(lock));
        mb();
 }