tests/bitarithm_timings: Fixed bugs#12714
Merged
aabadie merged 2 commits intoRIOT-OS:masterfrom Nov 15, 2019
Merged
Conversation
Member
Author
|
I think nobody started reviewing, so I squash the missing include in directly. |
634624c to
458e4d3
Compare
aabadie
reviewed
Nov 15, 2019
Contributor
aabadie
left a comment
There was a problem hiding this comment.
Thanks for fixing this test for AVR platforms!
I just tested it with success on arduino-uno, atmega256rfr2-xpro, native and samr21-xpro. So from the functional point of view, this PR is good.
Murdock doesn't seem to have problem with the use of C11 atomic but is this change really necessary to fix the test ?
aabadie
reviewed
Nov 15, 2019
13 tasks
Prevent bitarithm_lsb() from being called with 0, as it loops forever then
The tests used the volatile qualifier for two this:
1. Prevent the compiler to optimize out calls to the inline-able functions
bitarithm_msb, bitarithm_lsb, bitarithm_bits_set
2. Communication between IRQ context and thread context
While the first use is valid, the second is dangerous, see [1], [2], [3], [4].
This commit replaces the second use with C11 atomics, which were explicitly
added to the C standard to address this use case.
[1]: https://www.kernel.org/doc/html/latest/process/volatile-considered-harmful.html
[2]: http://c.isvolatileusefulwiththreads.com/
[3]: https://web.archive.org/web/20181124154026/http://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/
[4]: https://blog.regehr.org/archives/28
458e4d3 to
8854255
Compare
Member
Author
|
Thanks for the review! |
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.
Contribution description
Fixed bugs in tests/bitarithm_timings:
bitarithm_lsb()from being called with 0, as it loops forever thenvolatilefor stuff it is not meant to be usedTesting procedure
The test should now pass on ATmegas
Issues/PRs references
First item in #12651