cortexm_common: disable IRQ during thread_sched_idle [backport 2020.07]#14537
Merged
miri64 merged 1 commit intoRIOT-OS:2020.07-branchfrom Jul 16, 2020
Merged
Conversation
A race condition is present where an IRQ is serviced between the priority increase of the PENDSV and the sleep. When the IRQ is serviced before the WFI sleep, the core will sleep until the next IRQ and the thread activated by the IRQ will not be scheduled until a new IRQ triggers. This commit wraps an IRQ disable and restore around the priority modification and sleep to prevent interrupts from being serviced until the WFI call returns. (cherry picked from commit eec7aa2)
miri64
approved these changes
Jul 16, 2020
Member
miri64
left a comment
There was a problem hiding this comment.
Change is identical to the original PR to master.
81 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #14534
Contribution description
A race condition is present where an IRQ is serviced between the
priority increase of the PENDSV and the sleep. When the IRQ
is serviced before the WFI sleep, the core will sleep until the next
IRQ and the thread activated by the IRQ will not be scheduled until
a new IRQ triggers.
This commit wraps an IRQ disable and restore around the priority
modification and sleep to prevent interrupts from being serviced until
the WFI call returns.
Testing procedure
tests/test_toolsshould work on the iotlab_m3 (see tests/test_tools: fails oniotlab-m3due tocore/cpuregression #14521)tests/xtimer_periodic_wakeupshould work on the nucleo-l152 (see core: make idle thread optional #14224 (comment))Issues/PRs references
Fixes #14521
See #14224 (comment)