-
Notifications
You must be signed in to change notification settings - Fork 3k
Ticker class description update - small interval warning #5045
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
Conversation
drivers/Ticker.h
Outdated
@@ -100,6 +100,10 @@ class Ticker : public TimerEvent, private NonCopyable<Ticker> { | |||
* | |||
* @param func pointer to the function to be called | |||
* @param t the time between calls in micro-seconds | |||
* | |||
* @note setting t to very small value much less than RTOS tick frequency |
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.
I would reference the t @a t
also mention some numbers noting it's platform dependant.
332782a
to
47a939c
Compare
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.
Great addition 👍
Lets just hope we don't end up with a list of 100 platforms with their minimum wait period.
drivers/Ticker.h
Outdated
* @note setting @a t to very small value much less than RTOS tick frequency | ||
* can cause system malfunction or even system hang. By default OS tick frequency | ||
* is 1000Hz (1 tick == 1ms) so we schouldn't set much less then 1000us. | ||
* The lowest value which can be set without program hang is H/W dependent |
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.
This note makes it seem like there is a bug with the some implementations of the ticker which should not be the case. Depending on how much processing is done in the ticker interrupt and current cpu speed the values of t
which make the program hang could be arbitrarily large. For example, if your interrupt routine takes 11ms to complete, then a t
of 10,000 will cause a system hang.
Maybe a generic warning like this would be more appropriate?
setting @a t to a value shorter that it takes to process the ticker callback will cause the system to hang.
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.
Yeah, maybe you are right. Cutting a bit on details and maybe quoting the hardware specific danger zone below 500us(?) which should be safe for most platforms.
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.
I would say that:
timout > T1(calback exec time) + T2(task switch time)
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.
If we set Ticker callback time small enought to fall into endless processing loop there ist still chance to recover from this "hang" state putting some ticker control code inside callback which call detach
in suitable moment.
So maybe it's good idea to make comment/warrning short and let programmer to decide what time is good for him.
47a939c
to
19ee9c1
Compare
Bump for rereview, the comments were addressed |
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
Description
doxygen update
Status
READY