lv2: keep one authoritative semaphore count - #88
Open
canersaka wants to merge 2 commits into
Open
Conversation
Make the Win32 kernel semaphore a wake channel while value remains the only count. Wait and trywait consume value under the lock; post updates it first and wakes only parked waiters. This removes the grant-before-shadow-decrement window that could reject a valid post and drop its wake. Match the POSIX overflow result to CELL_EBUSY.
canersaka
marked this pull request as ready for review
July 25, 2026 05:57
sp00nznet
added a commit
that referenced
this pull request
Aug 15, 2026
tsautier
pushed a commit
to tsautier/ps3recomp
that referenced
this pull request
Aug 15, 2026
… ABI/lv2 batch) CONTRIBUTORS.md gains canersaka's six-PR batch (sp00nznet#83-sp00nznet#88); README gets an Unreleased changelog section covering everything folded via integrate/fold-2026-08-14, attributed per fix. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
The Win32 semaphore path kept the guest count twice: once in
sys_semaphore_info::valueand again in the kernel semaphore handle. wait and trywait consumed the kernel count and then decremented value separately, while post updated value before releasing the handle. Timeout and wake races could make those counts disagree, producing lost tokens, negative bookkeeping or a waiter sleeping while value was already positive. The overflow path also returned CELL_EINVAL instead of the lv2 CELL_EBUSY contract.This makes value under value_lock the only count on both host paths. The Win32 handle becomes a wake channel only, parked waiters recheck value under the lock, and post wakes at most
min(count, waiters). The second commit wires the existing sync_stress target into the test build with the small standalone shims it needs, so this behavior stays executable outside a generated title.Verified: ps3recomp_runtime builds clean and CTest passes the sync_stress target, 1 of 1 tests. On the unmodified base the same semaphore-counting section reports ten failures; on this branch its post, trywait, timed-wait and overflow checks all pass.