Skip to content

Commit

Permalink
spinlock: Fix ticket_spinlock::is_locked check
Browse files Browse the repository at this point in the history
If multiple waiters call ::lock, next_ticket_ is pushed forward
multiple times.
  • Loading branch information
qookei committed Nov 14, 2024
1 parent 805d23e commit 011c88c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/frg/spinlock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct ticket_spinlock {

bool is_locked() {
return (__atomic_load_n(&serving_ticket_, __ATOMIC_RELAXED) + 1)
== __atomic_load_n(&next_ticket_, __ATOMIC_RELAXED);
<= __atomic_load_n(&next_ticket_, __ATOMIC_RELAXED);
}

void unlock() {
Expand Down

0 comments on commit 011c88c

Please sign in to comment.