TcMenu / TaskManagerIO

A task, event, scheduling, and interrupt marshalling library for Arduino and mbed boards.
Apache License 2.0
124 stars 14 forks source link

Timing error when using multiple events. Out of order execution after some time #15

Closed davetcc closed 4 years ago

davetcc commented 4 years ago

The follow sketch will freeze after some time:

https://github.com/davetcc/LiquidCrystalIO/blob/master/examples/TaskMgrIntegration/TaskMgrIntegration.ino

It's not clear if all tasks are out of order, waiting behind a task with longer delay, or another problem.

davetcc commented 4 years ago

Once the cause is determined, add it to the task manager unit test cases.

davetcc commented 4 years ago

This has been located with high probability. TaskManagerIO is a cooperative scheduler which means it is inherently an unfair scheduler. As a result if a task constantly provides a 0 microsecond time to it's next execution, it will constantly run and it will not get around to running other tasks. Events should NEVER continually return 0 microseconds in their timeToNextCheck call.

We are soak testing the modified sketch and will close this issue when we don't see the issue after a day of execution.

davetcc commented 4 years ago

Ensure that the documentation makes clear that an event repeating with a 0 delay will never return control to anything else.