@@ -2,14 +2,23 @@ FreeRTOS
2
2
========
3
3
4
4
The SMP port of FreeRTOS is included with the core. This allows complex task operations
5
- and real preemptive multithreading in your sketches. To enable FreeRTOS, simply add
5
+ and real preemptive multithreading in your sketches. While the ``setup1 `` and ``loop1 ``
6
+ way of multitasking is simplest for most folks, FreeRTOS is much more powerful.
7
+
8
+ Enabling FreeRTOS
9
+ -----------------
10
+
11
+ To enable FreeRTOS, simply add
6
12
7
13
.. code :: c++
8
14
9
15
#include <FreeRTOS.h>
10
16
11
17
to your sketch and it will be included and enabled automatically.
12
18
19
+ Configuration and Predefined Tasks
20
+ ----------------------------------
21
+
13
22
FreeRTOS is configured with 8 priority levels (0 through 7) and a process for
14
23
``setup()/loop() ``, ``setup1()/loop1() ``, and the USB port will be created. The task
15
24
quantum is 1 millisecond (i.e. 1,000 switches per second).
@@ -19,8 +28,21 @@ only run in core 1 in this mode, the same as the default multithreading mode.
19
28
20
29
You can launch and manage additional processes using the standard FreeRTOS routines.
21
30
22
-
23
31
``delay() `` and ``yield() `` free the CPU for other tasks, while ``delayMicroseconds() `` does not.
24
32
33
+ Caveats
34
+ -------
35
+
36
+ While the core now supports FreeRTOS, most (probably all) Arduino libraries were not written
37
+ to support preemptive multithreading. This means that all calls to a particular library should
38
+ be made from a single task.
39
+
40
+ In particular, the ``LittleFS `` and ``SDFS `` libraries can not be called from different
41
+ threads. Do all ``File `` operations from a single thread or else undefined behavior
42
+ (aka strange crashes or data corruption) can occur.
43
+
44
+ More Information
45
+ ----------------
46
+
25
47
For full FreeRTOS documentation look at `FreeRTOS.org <https://freertos.org/index.html >`__
26
48
and `FreeRTOS SMP support <https://freertos.org/symmetric-multiprocessing-introduction.html >`__.
0 commit comments