-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/native: fix thread_yield_higher() with IRQs disabled #16754
cpu/native: fix thread_yield_higher() with IRQs disabled #16754
Conversation
tests/deferred_yield_higher/Makefile
Outdated
@@ -1,3 +1,5 @@ | |||
include ../Makefile.tests_common | |||
|
|||
BOARD_WHITELIST := native |
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.
Why not
BOARD_WHITELIST := native | |
FEATURES_BLACKLIST += arch_avr8 arch_msp430 |
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.
hm, I'm not sure about the others. but yes, that's nicer
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.
done, I've also added esp, mips and riscv, until they're confirmed to work.
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.
don't we have esp on CI?
I have esp on my desk, I can do the test just now.
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.
esp8266
/home/benpicco/dev/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyUSB3" -b "115200" --no-reconnect --noprefix --no-repeat-command-on-empty-line
Twisted not available, please install it if you want to use pyterm's JSON capabilities
Connect to serial port /dev/ttyUSB3
Welcome to pyterm!
Type '/exit' to exit.
READY
s
START
main(): This is RIOT! (Version: 2021.10-devel-380-ge4b3a)
1. post yield
2. second thread scheduled
3. post irq enable
works
esp32
/home/benpicco/dev/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyUSB3" -b "115200" --no-reconnect --noprefix --no-repeat-command-on-empty-line
Twisted not available, please install it if you want to use pyterm's JSON capabilities
Connect to serial port /dev/ttyUSB3
Welcome to pyterm!
Type '/exit' to exit.
READY
s
START
main(): This is RIOT! (Version: 2021.10-devel-380-ge4b3a)
1. post yield
2. second thread scheduled
3. post irq enable
works
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.
Doesn't esp need to be whiteliseted now @kaspar030 ?
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.
thanks @benpicco! I've removed the esp blacklist.
200 tests passed frdm-k22f
nucleo-f091rc
nucleo-f303re
nucleo-f767zi
nucleo-l152re
arduino-mega2560
nucleo-l432kc
saml10-xpro
saml11-xpro
samr21-xpro
nrf52dk
remote-revb
nucleo-f207zg
nucleo-l073rz
slstk3401a
nucleo-g474re
nucleo-f411re
nucleo-f103rb
frdm-kw41z
esp32-wroom-32
z1
arduino-due
slstk3400a
frdm-k64f
|
@riot-hil-bot is just trying things out. It wanted some real world test case. More info at the VMA. |
If you are looking for some input, if the posted results could link to the test logs (when failed) that would be awesome! |
@MrKevinWeiss only failure I find weird is |
Please squash! |
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.
ACK.
This makes native behave like Cortex-M, which flags PENDSV, which then gets triggered once IRQs are re-enabled.
This test verifies that a thread can call `thread_yield_higher()` with IRQs disabled, and that the actual context switch is deferred until IRQs are re-enabled.
0dfe049
to
fe1d998
Compare
Contribution description
This PR allows
thread_yield_higher()
to be called with IRQs disabled, on native. In that case, a deferred yield is executed once interrupts are re-enabled.That's the behavior on Cortex-M. IMO it would be nice to be able to depend on it.
A test is added for verifying this behavior.
The test verifies this behavior on all platforms though, and should thus be run on them.Should some platform not behave right, I suggest limiting the test to the working platforms, until this is sorted out.
At least msp430 and avr8 don't behave as required for this test, so I've marked it native only for now.
Testing procedure
As this was warned on and forbidden before, nothing should break. CI tests should be sufficient.
Issues/PRs references
The fix in #16751 could profit from this.