Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Renamings for thatesp_yield is really suspend, replacing delay(0), shimmable suspend-CONT API for async esp_suspend() / esp_schedule()#7148

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mcspr merged 22 commits intoesp8266:masterfromdok-net:delay0isyield
Oct 16, 2021

Conversation

@dok-net
Copy link
Contributor

@dok-netdok-net commentedMar 11, 2020
edited
Loading

The main API change here concerns the renaming ofesp_yield() toesp_suspend(). This can be detected by 3rd party libraries through the newHAVE_ESP_SUSPEND define.
Lots of internal renamings to make the difference between suspending and yielding, the latter meaning suspend and resume at the next opportunity, more succinct.

Hint: This PR now contains, due to sizeable merge efforts each time, and they are related, everything that's in PR#6782 as well.

Fixes#7969

Related items:
#6212, here is a more complete replacement of delay(0) usage across the Core
#8317 here, implement delay on a lower level
#7969 since we deal with a bunch of weak funcs, here internal libraries reference the exact functionality they want
#7146 discussion originated the UART changes, as noticed with the delay(0) vs. yield() usage

@dok-net
Copy link
ContributorAuthor

CI bombed again, this time for MacOS :-(

@dok-netdok-netforce-pushed thedelay0isyield branch 2 times, most recently from0513ce5 toc32b24aCompareMarch 26, 2020 16:32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

How about commenting the choice of this name (is it interrupting tasks calling (delay()) from cont stack) and also that it is equivalent todelay(0) ?

Copy link
Collaborator

@d-a-vd-a-vJan 9, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If new function names are to be added, with restrictions on usage, like "use esp_break() if code is called from SYS", I suggest adding_from_sys in its name to make it clear.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

yield() historically panics on purpose when it is called from SYS.
esp_break() is exactlyyield() withoutpanic(), callable from both cont and sys.
Considering that theyield()'spanic() is avoided bydelay(0) or its new flavouresp_break(), then we may just updateyield() to not panic no ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't know what happened, but you must not have available the current sources somehow.
The actual comment now states, I think I adapted it after an earlier discussion:

// Replacement for delay(0). In CONT, same as yield(). Whereas yield() panics// in SYS, esp_break() is safe to call and only schedules CONT. Use yield()// whereever only called from CONT, use esp_break() if code is called from SYS// or both CONT and SYS.

Meaning,esp_break() is intended for both SYS and CONT.
With regard toyield() panicking in SYS, whereasdelay(0) does not andesp_break() of course does neither, I think this was discussed and it was stated thatyield() shall intentionally continue panicking when called from anywhere else but CONT.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I forgot to disable my previous answer before the last one. Sorry that this confused you.

So you proposeesp_break() for both sys and cont becauseyield() is for cont only, while they both do the same job, likedelay(0) which currently is used to replaceyield() everywhere where it is needed for sys and cont.
Then, you replacedelay(0) by the new sys+contyield() taste.
So we have nowyield(),delay(0),esp_break() ?
Why not simplyyield() with a comment ?

If the earlier discussion you refer to isthat one, it also says:

We could fix it for a major release

@devyte maybe you can elaborate on this:

The expressibility issue has been discussed before (a long time ago shortly after I arrived). It was deemed valid

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@d-a-v Thanks, one can never look too many times at the code. I'm going to explain next that it's a bit different than you think, but that wasn't helped by me replacingdelay(0) byyield() on time too often - instead of byesp_break() (5c39094).

Then, you replace delay(0) by the new sys+cont yield() taste.
So we have now yield(), delay(0), esp_break() ?
Why not simply yield() with a comment ?

Delay(0) is either pointless, in those places where the code runs only ever from CONT, so for final clarity and to let the runtimepanic to express that contract, I'm replacing it byyield(). Again, only in those places.
Wherever code may run from SYS (and perhaps from CONT, too), the newesp_break() must be used to replacedelay(0). This is to make the intention clear not topanic in SYS, which I find obfuscated by a zero timedelay(0) call.
As you can see,yield() (intentional panic in SYS) is not the same asesp_break(), and my reservations aboutdelay(0) I've explained above.

@d-a-vd-a-v self-requested a reviewMarch 27, 2020 10:38
@dok-netdok-netforce-pushed thedelay0isyield branch 2 times, most recently from48a4cb2 to401670eCompareJanuary 4, 2021 21:18
@dok-netdok-netforce-pushed thedelay0isyield branch 2 times, most recently from4976bc6 to5c39094CompareJanuary 10, 2021 12:39
@dok-netdok-netforce-pushed thedelay0isyield branch 2 times, most recently from5f22bea tocd03fa9CompareMarch 15, 2021 10:48
@dok-netdok-netforce-pushed thedelay0isyield branch 3 times, most recently from24806f8 to8e92256CompareApril 8, 2021 10:53
@dok-netdok-net changed the titleDelay(0) is an obfuscation of yield() or esp_schedule(); esp_yield()Fix for: esp_yield really suspends, delay(0) is an obfuscation of yield() for CONT and SYSApr 8, 2021
@dok-netdok-net mentioned this pull requestApr 8, 2021
Closed
@dok-netdok-netforce-pushed thedelay0isyield branch 2 times, most recently froma3d08f1 to2a39360CompareApril 9, 2021 14:33
@d-a-v
Copy link
Collaborator

Strangely enough, I can't find any use of yieldUntil in the libraries/lwIP_Ethernet code itself, which we are told it is presented for.

Should we understand that you're in the need for a personalized explanation of why it is useful for ethernet ?

@dok-net
Copy link
ContributorAuthor

Not really... I've commented at times before about "separation of concern" issues, but let us not go deeper into that. Also, no need to get personal at all.
On the technical side, one, there is a template in PolledTimeout that includes the yield, using that would make the PR more terse. I could contribute the code change, if I didn't believe that the use of PolledTimeout, especially fast, wasn't a bad idea for slow networking code. Yes, you could rightfully claim that the PR I am pitching has a separation of concern problem in its own right, but alas, it has fixed those trouble spots that theyieldUntil addresses many moons earlier, so I stand by it, hoping to be able to field the right review questions and get your approval on technical grounds. Please read the issue that it solves, too.

@mcspr
Copy link
Collaborator

About template vs. std::function, my first attempt in this direction shows much worse memory efficiency

Strange, I was observing rom going down from 317933 before and 317853 after. Ram remained the same.

https://gist.github.com/mcspr/50e7c8ee2bc9c27bc8e83dd0e7aae111
With the general idea to move shared code externally, keeping the bare minimum inline

@dok-net
Copy link
ContributorAuthor

dok-net commentedOct 8, 2021
edited
Loading

@mcspr Thank you for your contribution. I may not have taken the time to analyze further otherwise. Yes, your change shaves 160 bytes off the IROM usage - that's for the pristine WiFiScan.ino example sketch. I'm committing your change, with a small refactoring of the const references on uint32_t that I think were unintended.
EDIT: I had to fix a subtle bug you introduced because of your thinking being influenced byyieldUntil. Please understand that in this PR, delays may become canceled by an asynchronousesp_resume, and the "blocked" predicate is there to test for some condition that may preempt delaying again until the timeout is fullfilled.

Copy link
Collaborator

@mcsprmcspr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

lgtm
besides the comments and the commit & title could be improved for squashing?

some historical reference

  • #6212, here is a more complete replacement of delay(0) usage across the Core
  • #8317 here, implement delay on a lower level
  • #7969 since we deal with a bunch of weak funcs, here internal libraries reference the exact functionality they want
  • #7146 discussion originated the UART changes, as noticed with the delay(0) vs. yield() usage

@dok-netdok-net changed the titleFix for: esp_yield really suspends, delay(0) is an obfuscation of yield() for CONT and SYSRenamings for thatesp_yield is really suspend, replacing delay(0), shimmable suspend-CONT API for async esp_suspend() / esp_schedule()Oct 13, 2021
@dok-netdok-net requested review frommcspr and removed request ford-a-vOctober 13, 2021 06:43
…ve microoptimization thatcould break on inlining.
Fix in-source specification for the main `esp_try_delay`.
@mcspr
Copy link
Collaborator

mcspr commentedOct 16, 2021
edited
Loading

@dok-net can you merge master branch here or unlock the modifications by the maintainers on the right column?

@dok-net
Copy link
ContributorAuthor

@mcspr Done

@mcsprmcspr merged commitc312a2e intoesp8266:masterOct 16, 2021
@mcsprmcspr added this to the3.1 milestoneOct 16, 2021
@dok-netdok-net deleted the delay0isyield branchOctober 16, 2021 21:58
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@d-a-vd-a-vd-a-v left review comments

@mcsprmcsprmcspr approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

WiFiScan.ino ported to CoopTask libraries doesn't find any networks

3 participants

@dok-net@mcspr@d-a-v

[8]ページ先頭

©2009-2025 Movatter.jp