mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-26 04:39:17 +08:00
19dc71ba22
Second phase of the 1:1 threading rework. Semaphores and event flags now block the guest thread's host thread in place on their existing gate object, dropping the RequestCurrentThreadBlock cooperative path, the Pump-driven fallback loop, and the WakeBlockedThreads wake-key hand-off. - sceKernelWaitSema / sem_wait: park on Monitor.Wait(gate); SignalSema/Cancel pulse. Monitor releases the gate and parks atomically, so a signal issued the instant before the park cannot be lost. Semantics follow FreeBSD ksem/sem_wait (acquire when count>=need, else sleep). The separate WaitSemaphoreOnHostThread fallback is folded into the one path. - sceKernelWaitEventFlag: park on Monitor.Wait(gate), re-evaluating the AND/OR pattern with optional clear on each wake (reusing the existing IsSatisfied/ApplyClearMode/TryCompleteSatisfiedWait helpers); Set/Cancel pulse. Removes the cooperative predicate/resume closures, the scheduler Pump fallback, and the RE-era wait-object/frame-chain diagnostics that only existed to debug the old lost-wake path. Waits are sliced (GuestThreadBlocking.WaitSliceMilliseconds) purely so teardown unwinds parked threads. Net removal of the WakeKey field, the per-handle wake-key formatting, and ~200 lines of dead machinery. Verified (Metal, headless, vs baseline): void 6.3M imports (unregressed, 0 stalls), Dream Sara / Dead Cells / Hades / Astro / Silent Hill / Lunar all unregressed — Dead Cells advanced 5.2M->10.3M and Hades holds ~35M/45s. Zero unrecovered crashes across all eight games (Astro's one fault is the pre-existing recovered TBB functor-construction race). All 351 Libs tests pass. Lunar's 800K stall is unchanged — its producer-never-runs root is deeper (equeue/main-thread, phases 3-4), not semaphore mechanics.