The SMP (multicore) port of FreeRTOS is included with the core. This allows complex
task operations and real preemptive multithreading in your sketches. While the
loop1 way of multitasking is simplest for most folks, FreeRTOS
is much more powerful.
To enable FreeRTOS, simply add
to your sketch and it will be included and enabled automatically.
Configuration and Predefined Tasks
FreeRTOS is configured with 8 priority levels (0 through 7) and a process for
setup1()/loop1(), and the USB port will be created. The task
quantum is 1 millisecond (i.e. 1,000 switches per second).
loop() are assigned to only run on core 0, while
only run in core 1 in this mode, the same as the default multithreading mode.
You can launch and manage additional processes using the standard FreeRTOS routines.
yield() free the CPU for other tasks, while
delayMicroseconds() does not.
While the core now supports FreeRTOS, most (probably all) Arduino libraries were not written to support preemptive multithreading. This means that all calls to a particular library should be made from a single task.
In particular, the
SDFS libraries can not be called from different
threads. Do all
File operations from a single thread or else undefined behavior
(aka strange crashes or data corruption) can occur.