error with 'timeIsInPeriod()' at a timer overflow
- Dominant language
- C++
- Stars
- 26
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
This error occurs at a timer overflow.
Say 'from' = 'to_a' = 0xFFFFFE7E and 'to_b' = 412
timeIsInPeriod() returns 'to_b' instead of 'to_a' an Minar sets a wrong 'last_dispatch'.
This happens after a dispatch of a periodic event when the next call of this event is 'behind' a timer overflow.
Minar then goes to sleep under the conditions described above.
And the next time it awakens, Minar starts to execute the periodic event at a very high speed, because 'root->call_before' is now past 'last_dispatch' and before 'now'.
Suggested fix:
```
static minar::tick_t minar::smallestTimeIncrement(minar::tick_t from, minar::tick_t to_a, minar::tick_t or_b){
if((to_a >= from && or_b >= from) || (to_a < from && or_b < from))
return (to_a < or_b)? to_a : or_b;
if(to_a >= from && or_b < from) // instead of: if(to_a > from && or_b < from)
return to_a;
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by inspecting minar::smallestTimeIncrement() and trace how its result sets last_dispatch after a periodic event crosses timer overflow. Reproduce the supplied from, to_a, and to_b values, then verify that the scheduler no longer enters high-speed periodic dispatch after waking.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100