mikaelpatel / Arduino-Scheduler

Portable Cooperative Multi-tasking Scheduler for Arduino

Home Page:https://mikaelpatel.github.io/Arduino-Scheduler/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve task stack allocation

mikaelpatel opened this issue · comments

The current stack top (s_top) does not reflect the actual stack allocated. The current frame size of the main task is added implicitly. If tasks are not started together in setup() there is a risk that stack size becomes smaller or larger depending on the frame size from where start() task is called.

A possible solution is to make the current stack top (s_top) a pointer instead of a size counter and use this to calculate the stack allocation. This would remove any offset that the call frame may have added.

Some further discussion and test sketch can be found on the Arduino forum. See topic http://forum.arduino.cc/index.php?topic=372119.msg2600608#msg2600608.

Please see commit b142a52.