esp-idf/examples/system/pthread
2022-12-12 16:56:20 +08:00
..
main system: fix printf format errors in all system and cxx examples 2022-12-12 16:56:20 +08:00
CMakeLists.txt tools: Increase the minimal supported CMake version to 3.16 2022-06-01 06:35:02 +00:00
pytest_pthread.py system: re-enable esp_event, real_time_stats and pthread examples and test for C2 2022-06-23 02:05:46 +00:00
README.md docs: changes docs supported targets tables 2022-07-14 08:26:32 +08:00

Supported Targets ESP32 ESP32-C2 ESP32-C3 ESP32-S2 ESP32-S3

Pthread Example

(See the README.md file in the upper level 'examples' directory for more information about examples.)

ESP-IDF provides implementations for many standard POSIX Threads (pthread) APIs. These APIs are impmlemented as thin wrappers around FreeRTOS APIs.

This example demonstrates how to create threads using this API, and how to use the ESP-IDF pthreads extension API to set default thread parameters for the related FreeRTOS tasks. For complete details about supported Pthreads APIs, consult the ESP-IDF Programmers Guide.

How to use example

Hardware Required

This example should be able to run on any supported Espressif SoC development board.

Configure the project

idf.py set-target esp32

(Replace esp32 with the name of the chip target you are using.)

idf.py menuconfig

Build and Flash

Build the project and flash it to the board, then run monitor tool to view serial output:

idf.py -p PORT flash monitor

(Replace PORT with the name of the serial port to use.)

(To exit the serial monitor, type Ctrl-].)

See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.

Example Output

Created thread 0x3ffaff74
Created larger stack thread 0x3ffb7ca8
This thread has ID 0x3ffb7ca8 and 15896 bytes free stack
This thread has ID 0x3ffaff74 and 2616 bytes free stack
Thread 0x3ffaff74 exiting
Thread 0x3ffb7ca8 exiting
Threads have exited

Created thread 0x3ffb44c8 with new default config
This thread has ID 0x3ffb44c8 and 32312 bytes free stack
Thread 0x3ffb44c8 exiting
Thread has exited