Espressif ESP32-S2 Programming Manual page 844

Table of Contents

Advertisement

Chapter 2. API Reference
Not Implemented
The pthread.h header is a standard header and includes additional APIs and features which are not implemented
in ESP-IDF. These include:
• pthread_cancel() returns ENOSYS if called.
• pthread_condattr_init() returns ENOSYS if called.
Other POSIX Threads functions (not listed here) are not implemented and will produce either a compiler or a linker
error if referenced from an ESP-IDF application. If you identify a useful API that you would like to see implemented
in ESP-IDF, please open a feature request on GitHub <https://github.com/espressif/esp-idf/issues> with the details.
ESP-IDF Extensions
The API
esp_pthread_set_cfg()
control how subsequent calls to pthread_create() will behave. Currently the following configuration can be
set:
• Default stack size of new threads, if not specified when calling pthread_create() (overrides
FIG_PTHREAD_TASK_STACK_SIZE_DEFAULT).
• RTOS priority of new threads (overrides CONFIG_PTHREAD_TASK_PRIO_DEFAULT).
• FreeRTOS task name for new threads (overrides CONFIG_PTHREAD_TASK_NAME_DEFAULT)
This configuration is scoped to the calling thread (or FreeRTOS task), meaning that
can be called independently in different threads or tasks. If the inherit_cfg flag is set in the current configuration
then any new thread created will inherit the creator's configuration (if that thread calls pthread_create()
recursively), otherwise the new thread will have the default configuration.
Examples
system/pthread
demonstrates using the pthreads API to create threads
cxx/pthread
demonstrates using C++ Standard Library functions with threads
API Reference
Header File
components/pthread/include/esp_pthread.h
Functions
esp_pthread_cfg_t
esp_pthread_get_default_config(void)
Creates a default pthread configuration based on the values set via menuconfig.
Return A default configuration structure.
esp_err_t
esp_pthread_set_cfg(const
Configure parameters for creating pthread.
This API allows you to configure how the subsequent pthread_create() call will behave. This call can be used
to setup configuration parameters like stack size, priority, configuration inheritance etc.
If the 'inherit'flag in the configuration structure is enabled, then the same configuration is also inherited in
the thread subtree.
Note Passing non-NULL attributes to pthread_create() will override the stack_size parameter set using this
API
Return
• ESP_OK if configuration was successfully set
• ESP_ERR_NO_MEM if out of memory
• ESP_ERR_INVALID_ARG if stack_size is less than PTHREAD_STACK_MIN
Espressif Systems
defined in the esp_pthreads.h header offers custom extensions to
esp_pthread_cfg_t
833
Submit Document Feedback
esp_pthread_set_cfg()
*cfg)
CON-
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Table of Contents

Save PDF