scheduler: use semaphore for event wakeups#14550
Open
rgrinberg wants to merge 1 commit into
Open
Conversation
Member
Author
|
@anmonteiro this is quite similar to your original PR except without the signal watching thread + pipe completely removed. If you could test this on macos, it would be appreciated. |
de9ef5e to
f58c3a6
Compare
Replace the dedicated signal watcher thread with C signal handlers that record pending signals in a static table and wake the scheduler event queue. The OCaml scheduler drains that table into signal events on the main thread, so SIGINT/SIGQUIT/SIGTERM, SIGCHLD, and SIGUSR2 stay integrated with the normal event loop. Block scheduler signals while spawning worker threads so those threads inherit a blocked signal mask, then leave the main thread unblocked after installing the C handlers. Use a C wakeup primitive for the event queue so signal handlers can wake an idle scheduler without calling into OCaml runtime synchronization. Preserve the quick repeated Ctrl-C emergency exit behavior and keep SIGUSR2 debug dumps working. Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
f58c3a6 to
2acad14
Compare
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.
scheduler: handle signals on the main thread
Replace the dedicated signal watcher thread with C signal handlers that record pending signals in a static table and wake the scheduler event queue. The OCaml scheduler drains that table into signal events on the main thread, so SIGINT/SIGQUIT/SIGTERM, SIGCHLD, and SIGUSR2 stay integrated with the normal event loop.
Block scheduler signals while spawning worker threads so those threads inherit a blocked signal mask, then leave the main thread unblocked after installing the C handlers.
Use a C wakeup primitive for the event queue so signal handlers can wake an idle scheduler without calling into OCaml runtime synchronization. Preserve the quick repeated Ctrl-C emergency exit behavior and keep SIGUSR2 debug dumps working.
Also set local XDG_RUNTIME_DIR values in affected cram tests so RPC registry files stay inside the writable test sandbox.