CommandQueueMT
: Fix sync command awaiters missing the chance
#91725
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.
The recent new implementation of waiting for a sync command to have run used
!=
to compare the sync head with the tail. The problem was that an awaiter could be notified due to thread scheduling at any point after the event. That means that, say, an awaiter of sync command3
could be awaken by the time sync command6
has already run.The fix is not as easy as using
<
instead because, as stated by a comment in the code, if wraparound ever happened, sync would break. Therefore, this PR adds some logic to reset the counters at the earliest opportunity so they never reach high values.Also, the mutex is unlocked to give an opportunity to awaiters of realizing the wait is over and go on.
As a bonus, the leftover
SYNC_SEMAPHORES
constant is removed.Fixes #91520.