Skip to content

Conversation

@taylordotfish
Copy link

As discussed in #37, use Ordering::SeqCst when unlocking the spinlock if the corresponding atomic operation had a requested ordering of SeqCst. Otherwise, the existing Release ordering should be fine. The lock operation can remain unconditionally Acquire; it always occurs as part of an “atomic” lock/unlock pair.

@Amanieu
Copy link
Owner

Amanieu commented Sep 29, 2023

GCC's libatomic does things differently: it effectively inserts a fence(SeqCst) both before acquiring the lock and after releasing it.

I am not completely sure which approach is the correct one.

Use `SeqCst` for both acquiring and releasing the spinlock when the
corresponding atomic operation is `SeqCst`. This may not be strictly
necessary, but it can't hurt.
@taylordotfish
Copy link
Author

Well, I should probably trust GCC's developers' understanding of atomics more than my own, and in any case, the extra assurance can't hurt, so I've modified the PR to acquire the lock with SeqCst when appropriate, as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants