Skip to content

Commit

Permalink
test memory model
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiJuWu committed Oct 8, 2023
1 parent 370a180 commit fab24e2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/nuttx/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ static inline spinlock_t up_testset(FAR volatile spinlock_t *lock)
#elif(CONFIG_ATOMIC)
static inline spinlock_t up_testset(FAR volatile spinlock_t *lock)
{
SP_DSB();
const static spinlock_t unlock = SP_UNLOCKED;
int success = atomic_compare_exchange_strong(lock, &unlock, SP_LOCKED);
SP_DSB();
if(success) return SP_UNLOCKED;
else return SP_LOCKED;
}
Expand Down

0 comments on commit fab24e2

Please sign in to comment.