Skip to content

Commit

Permalink
Add memory barriers on lock/unlock of SpinLock (#13050)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcardiff authored Feb 8, 2023
1 parent 33b55a4 commit 2d49b07
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/crystal/spin_lock.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ class Crystal::SpinLock
Intrinsics.pause
end
end
{% if flag?(:aarch64) %}
Atomic::Ops.fence :sequentially_consistent, false
{% end %}
{% end %}
end

def unlock
{% if flag?(:preview_mt) %}
{% if flag?(:aarch64) %}
Atomic::Ops.fence :sequentially_consistent, false
{% end %}
@m.lazy_set(0)
{% end %}
end
Expand Down

0 comments on commit 2d49b07

Please sign in to comment.