-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Shimmable suspend-CONT API for async esp_yield() / esp_schedule() "stop the Arduino world" metaphor #6782
Conversation
FYI: Alters part of #6107. Conflicts/supersedes #6212. Of interest besides the obvious Arduino incompatibility, in my mind is the question of scheduling efficiency: does the esp scheduler internally consume a significantly different number of cycles for a suspended ( |
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.
This will require extensive testing for functional correctness in different scenarios, behavior if new code vs. current,. and power usage.
About that last, it is my understanding that a loop-yield is more cpu intensive than a loop-delay (n). Also, the sweet spot for such loops is delay(5), determined both from past experiences and from independent conclusions reached recently by @Tech-TX.
At a glance, I see at least one code change that changes behavior: replacing delay(0) by yield(). They are not equivalent in this context. I suspect apps that scan from SYS, e. g. from callbacks that run there, would break.
I'll leave specific comments once I review in detail.
@devyte Delay(0) vs yield() in master, actual code path unrolled, illegal (panic) path and do nothing pruned: delay(0) =>
yield() =>
|
|
Before you dive in, let me digest the input you have given me w.r.t. power and performance. On a hunch, I think I have an idea involving just a rename and weak bindings, that leave behavior unchanged without shims, AND let's me recover those coveted cycles for MT when needed. I'll let you know. Thanks for the valuable feedback.
|
No hurry, this is one of those cases where extremely careful consideration and thought is needed, or you risk breaking/worsening very subtle things that eventually blow things up in seemingly unrelated places. I suggest taking your time, doing broad and careful testing, and reporting your findings/progress back here for further discussion. |
3ecedc5
to
d30f0b1
Compare
With the latest commit, this PR is supposed to introduce basically no difference in behavior over master, when the weak bindings are not touched.
Use For any
|
20d3d9c
to
df917d6
Compare
df917d6
to
5292b2f
Compare
09b3ddc
to
6143da6
Compare
6be60a4
to
9133c23
Compare
9133c23
to
9a888e7
Compare
7748ea0
to
905f269
Compare
e65a724
to
d07620d
Compare
…ptible delays and suspending yields.
…le) by esp_yield inside guard loop
…s esp_yield and esp_delay with function arguments.
Add host mockup for esp_delay overload
…rgument for C-style FP is now ONLY in 3rd template argument.
… ptr with arg is possible).
…scriptive esp_suspend(...). Provide esp_suspend(void) as wrapper for esp_yield().
… don't thrash the recurrent functions scheduler by using intvl_ms != 0. Keeping the MCU out of the idle task increases power consumption.
This PR was included in merge c312a2e, and is therefore withdrawn. |
In order to let Arduino-like scheduling libraries, that shim yield() and/or delay(), make use of CPU cycles that are available while async callbacks are awaited, the CONT task must not be completely stopped.
This PR changes the way async callbacks are handled in ESP8266WiFi, currently the only code that works with NonOS async callbacks in ESP8266 Arduino core and core libraries according to Unix grep.
Fixes #7969