1ESP-pthread
2===========
3
4Overview
5--------
6
7This 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:
8
9  * Stack size of the pthreads
10  * Priority of the created pthreads
11  * Inheriting this configuration across threads
12  * Thread name
13  * Core affinity / core pinning.
14
15Example to tune the stack size of the pthread:
16
17.. code-block:: c
18
19    void * thread_func(void * p)
20    {
21        printf("In thread_func\n");
22        return NULL;
23    }
24
25    void app_main(void)
26    {
27        pthread_t t1;
28
29        esp_pthread_cfg_t cfg = esp_create_default_pthread_config();
30        cfg.stack_size = (4 * 1024);
31        esp_pthread_set_cfg(&cfg);
32
33        pthread_create(&t1, NULL, thread_func);
34    }
35
36The API can also be used for inheriting the settings across threads. For example:
37
38.. code-block:: c
39
40    void * my_thread2(void * p)
41    {
42        /* This thread will inherit the stack size of 4K */
43        printf("In my_thread2\n");
44
45        return NULL;
46    }
47
48    void * my_thread1(void * p)
49    {
50        printf("In my_thread1\n");
51        pthread_t t2;
52        pthread_create(&t2, NULL, my_thread2);
53
54        return NULL;
55    }
56
57    void app_main(void)
58    {
59        pthread_t t1;
60
61        esp_pthread_cfg_t cfg = esp_create_default_pthread_config();
62        cfg.stack_size = (4 * 1024);
63        cfg.inherit_cfg = true;
64        esp_pthread_set_cfg(&cfg);
65
66        pthread_create(&t1, NULL, my_thread1);
67    }
68
69API Reference
70-------------
71
72.. include-build-file:: inc/esp_pthread.inc
73
74