Repository navigation
Conversation
The m68k fallback returned the value it stored instead of the previous contents. This left spin locks permanently contended on their first acquisition. Preserve the old value and add coverage for spin trylock, lock, unlock and pthread_once.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
__sync_lock_test_and_setfallback return the value that wasin the lock before the exchange;
pthread_once.Why
GCC defines
__sync_lock_test_and_setas an atomic exchange that returns theprevious contents. The m68k fallback wrote the requested value and returned
that same value. Consequently the first acquisition of a clear spinlock wrote
one and reported one:
pthread_spin_trylock()returnedEBUSY, whilepthread_spin_lock()kept yielding indefinitely. This is reached bylibstdc++/Mesa through
pthread_once()before rendering starts.The fix preserves the old value while interrupts are disabled and returns it
after the exchange. It does not change the existing m68k locking model. The
separate m68k compare-and-swap fallback is outside this PR.
This is one commit directly on AROS
masterand has no PR dependencies.Validation
libpthread.abuilds for linux-x86_64 and amiga-m68k;-Wall -Wextra -Werroron both targets;the store and returns that saved value;
git diff --checkpasses.The m68k test binary was cross-built but was not executed on m68k hardware or
an emulator during this validation.