-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fix watchdog termination #341
Conversation
Zephyr fails because additional "user threads" must be specified. We have previously used compile defs for this. We might consider adding a LF_NUM_WATCHDOGS. A problem is however that the zephyr implementation does not work well with dynamically creating and destroying threads. Since I did add a condition variable we could probably make it work without terminating the watchdog thread at each timeout |
I think the idea with watchdogs was that on embedded platforms they would be implemented using a timer rather than thread. This will require an addition to the platform.h abstraction, I think, where the default implementation uses a thread. But with Zephyr, it seems like maybe there is a way to implement it with a timer?
|
I remember we discussed an algorithm to implement watchdogs without threads, with an ISR. For Zephyr, I think using a thread is OK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are very useful changes. This should fix the long-standing bug but also properly puts the watchdog timer in the environment. However, I'm not sure, but I think there might be a flaw that could cause watchdogs to be randomly cancelled. Should be an easy fix, though. See detailed comments.
Thanks Edward. You are right about the spurious wakeups of lf_cond_timedwait. I also just remembered the issue with lf_cond_timedwait needing an absolute wakeup-time wrt CLOCK_REALTIME, however lf_time_physical is wrt CLOCK_MONOTONIC. It is related to our discussion on #289. It means that before going to sleep on a cond_var we need to check the offset between CLOCK_MONOTONIC and CLOCK_REALTIME and adjust for it. We would make it easier for ourselves if we didn't try to solving the clock synchronization problem within the LF runtime and instead just used CLOCK_REALTIME and require that the underlying system is configured correctly |
In order to properly implement the watchdog termination I need to first get #346 merged. |
…g whether the system is sleeping between tags.
…tion. Dont join on watchdog thread when terminating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Edward
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I've made some code clarity suggestions. Also, I'm not sure about the active
field. I inserted a question.
@edwardalee thanks for the suggestions improving the readability of the main loop of the watchdog thread. I replied to a comment on the active field somewhere. The active field is only written to by the watchdog thread and it indicates whether it has stopped/timed-out or whether it is actively waiting for a time-out. If it is the former, then a call to If this makes sense, lets get this merged |
Merged this and queued the corresponding merge in lingua-franca. |
This PR address this issue. It also moves the watchdogs to the environment struct and should be merged with this PR in lingua franca.
This PR does a couple of things: