Chapter 4. API Guides
are specified in bytes.
Execution
The anatomy of a task in ESP-IDF FreeRTOS is the same as Vanilla FreeRTOS. More specifically, ESP-IDF FreeR-
TOS tasks:
• Can only be in one of following states: Running, Ready, Blocked, or Suspended.
• Task functions are typically implemented as an infinite loop
• Task functions should never return
Deletion
Task deletion in Vanilla FreeRTOS is called via vTaskDelete(). The function allows deletion of another task
or the currently running task (if the provided task handle is NULL). The actual freeing of the task's memory is
sometimes delegated to the idle task (if the task being deleted is the currently running task).
ESP-IDF FreeRTOS provides the same
are some behavioral differences when calling
• When deleting a task that is pinned to the other core, that task's memory is always freed by the idle task of
the other core (due to the need to clear FPU registers).
• When deleting a task that is currently running on the other core, a yield is triggered on the other core and the
task's memory is freed by one of the idle tasks (depending on the task's core affinity)
• A deleted task's memory is freed immediately if...
– The tasks is currently running on this core and is also pinned to this core
– The task is not currently running and is not pinned to any core
Users should avoid calling
the fact that it is difficult to know what the task currently running on the other core is executing, thus can lead to
unpredictable behavior such as...
• Deleting a task that is holding a mutex
• Deleting a task that has yet to free memory it previously allocated
Where possible, users should design their application such that
known state. For example:
• Tasks self deleting (via vTaskDelete(NULL)) when their execution is complete and have also cleaned up
all resources used within the task.
• Tasks placing themselves in the suspend state (via vTaskSuspend()) before being deleted by another task.
4.14.4 SMP Scheduler
The Vanilla FreeRTOS scheduler is best described as a Fixed Priority Preemptive scheduler with Time Slicing
meaning that:
• Each tasks is given a constant priority upon creation. The scheduler executes highest priority ready state task
• The scheduler can switch execution to another task without the cooperation of the currently running task
• The scheduler will periodically switch execution between ready state tasks of the same priority (in a round
robin fashion). Time slicing is governed by a tick interrupt.
The ESP-IDF FreeRTOS scheduler supports the same scheduling features (i.e., Fixed Priority, Preemption, and Time
Slicing) albeit with some small behavioral differences.
Espressif Systems
vTaskDelete()
vTaskDelete()
vTaskDelete()
on a task that is currently running on the other core. This is due to
Submit Document Feedback
function. However, due to the dual core nature, there
in ESP-IDF FreeRTOS:
vTaskDelete()
1360
is only ever called on tasks in a
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?