-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix for issue #6054 - interrupts scheduled in the past. #6068
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 for issue #6054 - interrupts scheduled in the past. #6068
Conversation
/morph build |
Build : SUCCESSBuild number : 1125 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 802 |
Test : SUCCESSBuild number : 932 |
hal/mbed_ticker_api.c
Outdated
@@ -235,6 +235,12 @@ static void schedule_interrupt(const ticker_data_t *const ticker) | |||
} | |||
|
|||
timestamp_t match_tick = compute_tick(ticker, match_time); | |||
if (match_tick == queue->tick_last_read) { |
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.
Isn't this suppose to be <= instead of ==?
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.
Basically interrupt which is to be scheduled in the past should be caught by the following check:
Line 232 in ccff46d
if (match_time <= present) { |
While debugging issue issue #6054 I did not found case when match_tick < queue->tick_last_read
which does not mean that such case can not occur. I think that it is worth to consider proposed change (even it it can never happen) since in such case interrupt for sure should be fired immediately.
@c1728p9 what is your opinion?
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 checked the impact of such change (GCC_ARM/K64F) and tests-mbed_hal-ticker
test fails (test_insert_event_us_outside_overflow_range
test case).
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.
Match tick could have rolled over so <=
cannot be used.
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 maybe add a comment line on this, as it's non-obvious - "The time has been checked to be future, but it could still round to the last tick" or something.
When ticker is not driven by the 1 MHz clock and HAL driver need to perform conversion between microseconds and ticks, then the interrupt might be scheduled in the past. For details see: ARMmbed#6054. This patch provides fix for such case. Interrupt is fired immidiatelly when last read tick is equal to the calculated tick when interrupt should be generated.
1ce8f95
to
c2760be
Compare
Added comment as suggested. |
/morph build |
Build : SUCCESSBuild number : 1149 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 824 |
Test : SUCCESSBuild number : 955 |
Description
When ticker is not driven by the 1 MHz clock and HAL driver need to perform conversion between microseconds and ticks, then the interrupt might be scheduled in the past. For details see issue #6054.
This patch provides fix for such case. While scheduling next interrupt an interrupt is fired immediately when ticker last read tick is equal to the calculated tick when interrupt should be generated.
Status
READY
Migrations
NO
Related PRs
List related PRs against other branches: