Cooperative multitask scheduler


I have seen this topic Has someone used this library? If yes how do you calculate the size of the stack for each task?



You can calculate if you have all the necessary data - call stack depth, local variables for each invoked function, etc. Just add them up and add a safety margin. But usually, you don't have those and they are succeptible to change whenever you modify your code. So that leaves you with doing good guesswork. If you do it wrong, the stacks will overflow, which you really don't want.

Because of the limited RAM, these problems are the main reason why multitasking sees so little use on the Arduino. If you really need it, use a platform better suited with more memory and if you don't, avoid multitasking.


Thanks, i will used another method for simulate multitasking.