Callbacks: A notify takes the thread out of its CB wait right away

On hardware, notifying a callback of a thread in a CB wait takes it out of
the wait at once, even though the callback only runs when the thread would
get the CPU. A semaphore signalled in between doesn't end the wait: the
callback runs first, then the wait resumes and takes it (pspautotests
threads/callbacks/combos). We left the thread on the wait list until the
callback started, so the signal ended the wait and the callback didn't
run.

The notify now pauses the wait, as starting a callback used to. If the
callbacks are canceled before the thread's turn comes, the wait just
resumes (Thread savestate section version 7).

threads/callbacks/combos goes in the to-do list: a callback returning to
the thread that notified it still takes ~13us where hardware takes ~9,
part of the context switch cost.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-09-30 09:06:30 -06:00
1 parent fb9ac8397e
commit a17a9eb147
3 files changed
+33 -2

No files matched your search

+1
View File
@@ -606,6 +606,7 @@ tests_next = [
# These two mbx tests only appeared to work because they papered over bugs
"threads/callbacks/combos",
"threads/scheduling/scheduling",
"threads/threads/create",
"threads/tls/memory",