Skip to content

Commit

Permalink
fix: ticket-spinlock trylock
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiJuWu committed Oct 5, 2023
1 parent 4f362c5 commit e75db46
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sched/semaphore/spinlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,12 @@ spinlock_t spin_trylock(FAR volatile spinlock_t *lock)
return SP_LOCKED;
}

ticket_spinlock_t old = atomic_load((ticket_spinlock_t *)lock);
ticket_spinlock_t new = old;
ticket_spinlock_t old;
ticket_spinlock_t new;

old = atomic_load((ticket_spinlock_t *)lock);
old.owner = old.next;
new = old;
new.next += 1;

bool success = atomic_compare_exchange_strong((ticket_spinlock_t *)lock,
Expand Down

0 comments on commit e75db46

Please sign in to comment.