mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
1953af4fb2
docs: update system api reference chapters for C3 Closes IDF-2327 and IDF-2320 See merge request espressif/esp-idf!12730
74 lines
1.6 KiB
ReStructuredText
74 lines
1.6 KiB
ReStructuredText
ESP-pthread
|
|
===========
|
|
|
|
Overview
|
|
--------
|
|
|
|
This module offers Espressif specific extensions to the pthread library that can be used to influence the behaviour of pthreads. Currently the following configuration can be tuned:
|
|
|
|
* Stack size of the pthreads
|
|
* Priority of the created pthreads
|
|
* Inheriting this configuration across threads
|
|
* Thread name
|
|
* Core affinity / core pinning.
|
|
|
|
Example to tune the stack size of the pthread:
|
|
|
|
.. code-block:: c
|
|
|
|
void * thread_func(void * p)
|
|
{
|
|
printf("In thread_func\n");
|
|
return NULL;
|
|
}
|
|
|
|
void app_main(void)
|
|
{
|
|
pthread_t t1;
|
|
|
|
esp_pthread_cfg_t cfg = esp_create_default_pthread_config();
|
|
cfg.stack_size = (4 * 1024);
|
|
esp_pthread_set_cfg(&cfg);
|
|
|
|
pthread_create(&t1, NULL, thread_func, NULL);
|
|
}
|
|
|
|
The API can also be used for inheriting the settings across threads. For example:
|
|
|
|
.. code-block:: c
|
|
|
|
void * my_thread2(void * p)
|
|
{
|
|
/* This thread will inherit the stack size of 4K */
|
|
printf("In my_thread2\n");
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void * my_thread1(void * p)
|
|
{
|
|
printf("In my_thread1\n");
|
|
pthread_t t2;
|
|
pthread_create(&t2, NULL, my_thread2, NULL);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void app_main(void)
|
|
{
|
|
pthread_t t1;
|
|
|
|
esp_pthread_cfg_t cfg = esp_create_default_pthread_config();
|
|
cfg.stack_size = (4 * 1024);
|
|
cfg.inherit_cfg = true;
|
|
esp_pthread_set_cfg(&cfg);
|
|
|
|
pthread_create(&t1, NULL, my_thread1, NULL);
|
|
}
|
|
|
|
API Reference
|
|
-------------
|
|
|
|
.. include-build-file:: inc/esp_pthread.inc
|
|
|