Repository navigation
hal: read threads_running once per thread pass - #4896
Merged
Merged
Conversation
grandixximo
force-pushed
the
thread-start-race
branch
from
November 24, 2026 03:29
78ee203 to
9139cd8
Compare
thread_task() read hal_data->threads_running twice: once to decide on the init pass, once for the cyclic pass. A start that lands between the two reads runs the cyclic functions once before the init functions, and the init pass that follows runs no cyclic functions, so that cycle is missing for every function on the thread. Read it once per pass. Seen with the virtual time of LinuxCNC#4893 under load: timedelta reported a maximum of two periods in about one run out of a hundred, none in 130 runs with the fix.
grandixximo
force-pushed
the
thread-start-race
branch
from
November 24, 2026 07:45
9139cd8 to
7c570a5
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.
thread_task()readshal_data->threads_runningtwice: once to decide on the init pass, once for the cyclic pass. A start that lands between the two reads runs the cyclic functions once before the init functions. The init pass that follows runs no cyclic functions, so one cycle is missing for every function on the thread.The fix reads it once per pass.
I found it with the virtual time of #4893 under load:
timedeltareported a maximum of two periods in about one run out of a hundred, and none in 130 runs with the fix. I have no deterministic test for it; the window is two adjacent reads. The thread, HAL and rtapi tests pass.