Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scx_loader: Avoid race condition with start_scheduler #1225

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

taoky
Copy link
Contributor

@taoky taoky commented Jan 19, 2025

When RunnerMessage::Switch is called frequently, start_scheduler could encounter a race condition issue, where more than one tokio async task would start the same time, messing with the child_id state.

To resolve this issue, the JoinHandle got in start_scheduler is recorded, and instead of using child_id to send SIGINT, a cancellation token from tokio-util is used, and stop_scheduler uses it to inform the async task to kill its child. And we could ensure that only one task is managing spawned scheduler process.

When RunnerMessage::Switch is called frequently, start_scheduler could
encounter a race condition issue, where more than one tokio async task
would start the same time, messing with the child_id state.

To resolve this issue, the JoinHandle got in start_scheduler is
recorded, and instead of using child_id to send SIGINT, a cancellation
token from tokio-util is used, and stop_scheduler uses it to inform the
async task to kill its child. And we could ensure that only one task is
managing spawned scheduler process.
taoky added a commit to taoky/scripts that referenced this pull request Jan 20, 2025
@htejun htejun enabled auto-merge January 22, 2025 00:04
@htejun htejun added this pull request to the merge queue Jan 22, 2025
Merged via the queue into sched-ext:main with commit 6c32a68 Jan 22, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants