Italian developer
Leonardo Miliani laid out the open source sources of leOS (little embedded operating system) - a small multitasking kernel for Arduino. In his blog he writes:
It is really a real-time operating system (RTOS) and a scheduler. [...]
It is clear that it can be used to run through the main loop.
The leOS core provides dispatching of user function calls according to specified time intervals. To do this, leOS uses hardware Timer2 to count the intervals between calls to user-defined functions, so access to the PWM functions on the D3 and D11 pins is lost. The kernel uses a 64-bit counter, so the scheduler will overflow only after 584,942,417 years.
To use leOS, you need to connect the library and create an instance of the class:
#include "leOS.h" leOS myOS;
The user function is connected to the scheduler using the
addTask () method:
void setup() { myOS.begin(); myOS.addTask(myFunction, interval); .... }
More information and leOS source codes can be found
here .