Skip to content

hal: Update functs and threads to use getter/setter - #4307

Merged
grandixximo merged 1 commit into
LinuxCNC:masterfrom
BsAtHome:halgs_functs-threads
Aug 1, 2026
Merged

hal: Update functs and threads to use getter/setter#4307
grandixximo merged 1 commit into
LinuxCNC:masterfrom
BsAtHome:halgs_functs-threads

Conversation

@BsAtHome

Copy link
Copy Markdown
Contributor

This fixes the HAL library internals to use getter/setter. Specifically threads and functions running in threads are setting some pins/params (.time, .tmax, etc).

Note that the update to (non-functional) halrmt is purely circumstantial to keep the compiler happy because it has not yet been updated to the query API. It will be changed soon enough.

This PR also adds a <threadname>.threadbeat pin that monotonically increases whenever the thread is running and executing functions in its cycle. It is in essence a cycle counter.

The threadbeat cycle counter can be used to prevent races between non-RT and RT (instead of unreliable sleep constructs). You can simply read the pin and see it change. You know that the number of thread cycles executed is equal to the numerical change. You can simply wait for the threadbeat to have advanced by N when non-RT knows that at least N cycles are required to perform the operation being waited for. You should still wait in a non-busy-loop way. Especially test-scenarios should use it, where appropriate, instead of sleep because test/CI machines may be very busy and unreliable when using calls to sleep() and you expect something to have happened after that period of time.

@grandixximo
grandixximo merged commit 01f23a3 into LinuxCNC:master Aug 1, 2026
16 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.

2 participants