Scheduling¶
This package supports a common interface for running tasks and background
threads. This support is included with kasl/scheduling.h; three functions
are provided:
void kasl::scheduleThreadadds a thread to be scheduled. This should be called beforestartScheduler.void kasl::startSchedulerinitialises the scheduler.void kasl::runSchedulerruns an interation of the scheduler. This should be placed in the main loop.
Platform specific notes¶
- Atmel SAMD boards (
src/scheduling_atmelsamd.cc):startSchedulerandrunSchedulerare nops provided to keep a common interface for code that needs to run on multiple architectures.- The standard Arduino Scheduler is used.
- There isn’t a hard limit on the number of threads that can be run.
- Other boards (
src/scheduling_default.cc):- There is a limit to the number of tasks that can be scheduled; this is
controlled by the
MAX_TASKSdefine, with a default of 8. This can be tuned to save memory, e.g. on the AVR boards. - Threads are scheduled to run every
SCHEDULER_FREQUENCYmilliseconds; the default is 50. - These settings can be changed under
build_flagsin the environment. Seeexamples/schedutestfor an example.
- There is a limit to the number of tasks that can be scheduled; this is
controlled by the