Blame | Last modification | View Log | Download
# Arduino-SchedulerThis library implements an extended sub-set of the Arduino Schedulerclass. Multiple loop() functions, tasks, may be started and run in acollaborative multi-tasking style. The tasks are run until they callyield() or delay(). The Arduino yield() function is replaced by animplementation in the library that allows context switching.Tasks should be viewed as static and continuous. This implementationdoes not allocate tasks on the heap. They are allocated on the normalstack and linked into a cyclic run queue. One-shot tasks are notsupported. Instead the task start function is extended with a setupfunction reference. Tasks are started with:````Scheduler.start(taskSetup, taskLoop [,taskStackSize]).````The tasks will start execution when the main task yields. The_taskSetup_ is called first and once by the task followed by repeatedcalls to _taskLoop_. This works just as the Arduino setup() and loop()functions. There is also an optional parameter, _taskStackSize_. Thedefault value depends on the architecture (128 bytes for AVR and 512bytes for SAM/SAMD/Teensy 3.1).The Scheduler is a single-ton and the library creates the singleinstance.This library also includes support for task synchronization andcommunication; Semaphores, Queues and Channels.## InstallDownload and unzip the Arduino-Scheduler library into your sketchbooklibraries directory. Rename from Arduino-Scheduler-master to Arduino-Scheduler.The Scheduler library and examples should be found in the Arduino IDEFile>Examples menu.## PerformanceThere are several benchmark sketches in the examples directory. Beloware some of the results.### Context SwitchBoard | us | cycles------|----|-------Arduino Mega 2560 (16 MHz) | 12.64 | 203Arduino Uno, Nano, Pro-Mini, etc (16 MHz) | 11.00 | 176Sparkfun SAMD21 (48 MHz) | 2.60 | 125Arduino Due (84 MHz) | 1.36 | 115Teensy 3.1 (72 MHz) | 1.10 | 80### Max Tasks (default stack size)Board | Tasks | Stack (bytes)------|-------|--------------Arduino Uno, Nano, Pro-Mini, etc (16 MHz) | 9 | 128Sparkfun SAMD21 (48 MHz) | 26 | 512Teensy 3.1 (72 MHz) | 26 | 512Arduino Mega 2560 (16 MHz) | 48 | 128Arduino Due (84 MHz) | 52 | 512### Memory FootprintBoard | PROGMEM | SRAM (bytes)------|---------|-------------Arduino Due (84 MHz) | 224 | NAArduino Uno, Nano, Pro-Mini, etc (16 MHz) | 546 | 42Arduino Mega 2560 (16 MHz) | 548 | 44Sparkfun SAMD21 (48 MHz) | NA | NATeensy 3.1 (72 MHz) | NA | NA