EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1371 background imageLoading...
Page #1371 background image
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 tasks memory is
sometimes delegated to the idle task (if the task being deleted is the currently running task).
ESP-IDF FreeRTOS provides the same vTaskDelete() function. However, due to the dual core nature, there
are some behavioral differences when calling vTaskDelete() in ESP-IDF FreeRTOS:
When deleting a task that is pinned to the other core, that tasks 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
tasks memory is freed by one of the idle tasks (depending on the tasks core affinity)
A deleted tasks 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 vTaskDelete() on a task that is currently running on the other core. This is due to
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 vTaskDelete() is only ever called on tasks in a
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 1360
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish