-
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
implement EspClass::getFreeSysStack method #5153
Conversation
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 calculation gets the current stack usage at the time of call.
The getFreeContStack() gets the maximum stack usage from boot time by checking the stack watermark. The value returned can never decrease over time.
The meanings are fundamentally diifferent.
I would suggest figuring out a way to get the max sys stack usage in the same way that the max cont stack usage is done, because that is most useful, and can detect if a stack overflow has happened in the past.
I didn't realize getFreeContStack works that way. For now have two problems with implementing same approach for sys stack.
BTW, whats the meaning of cont abbreviation? |
Actually, there's a new API that makes more sense than trying to find the high water mark. Look at #5133 where the "get free stack" is added to the ESP class. You can't really fill the OS stack unless you patch the startup code, which is probably not worth the effort. |
@earlephilhower #5133 is a thin wrapper around cont_get_free_stack(), which looks at the cont stack watermark. The cont stack is filled with a guard value on init, and usage overwrites those values. The watermark is checked by starting at the end and counting the guard values while moving inwards. My previous effort is aimed at doing something similar for the sys stack. |
Did not see that, @devyte . While I can see its use, from my own experience the answer to the question "How much stack do I have now?" is much more interesting and given the name of the ESP function that's actually what I would expect... For sanity this should match the existing behavior, though. There is no task stack structure on startup, so @toomasz would need to find the current stack and then somehow safely fill from end-of-stack to |
Thinking back, I've actually found the need for both. Maybe the current method in #5133 should be renamed to getMaxContStackUse(), then a new method should be implemented for the current use, and then do the same for the sys stack. What do you think? |
We may have both views: |
Reference: sys stack area and painting by @eriksl |
I think we should have 4 methods then:
|
Not sure if implemetation is correct.
Did simple test:
And output was:
See comments in #5148