mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-28 01:15:04 -04:00
1176609890
The "Semaphore poll/signal remains stable under host-thread contention" test created the semaphore full (init == max == 1), so SignalSema could only succeed after PollSema had already freed a slot. With no start barrier, under host-thread contention the signaler thread could run all 64 of its iterations before the poller's first timeslice, making every SignalSema legitimately return KE_SEMA_OVF and leaving signalOkCount at 0 — a false failure of "contended SignalSema should observe successful releases". An earlier investigation of the unfixed test observed this twice in 24 contended (8-way-parallel) full-suite runs and never in 20 serial runs; CI has independently hit the same assertion on the unrelated draft PR #174, confirming the trigger is host scheduling, not the code under review. Seed the semaphore with headroom (init=1, max=2) so the first PollSema and the first SignalSema each succeed regardless of scheduling order, and add a start barrier so both workers start together, maximizing the opportunity to interleave. Widen the final-count range check to the new max. The semaphore implementation is unchanged; both threads still contend concurrently on the same per-semaphore mutex.