Hi,
I'm looking for information regarding thread safety in ESP-IDF.
For example, is it safe to to call esp_wifi_*, tcpip_adapter_* and other IDF APIs from the callback given to esp_event_loop_init()? Likewise, is it safe to call them from a FreeRTOS-thread?
The only information I've found re. this topic are the hits when [url?http://esp-idf.readthedocs.io/en/latest ... ea=default]searching the docs[/url], which only mentions that the I2C API and sdmmc_host_init() are not thread safe. Not quite the amount of information I was hoping for.
Thanks,
P
Thread safety
Re: Thread safety
Yes, both the APIs you mention are thread safe (they queue requests onto different tasks as necessary.) They can be called from event callbacks or from any other task (do not call them from interrupt context.)
In general, you should be able to assume an IDF API is thread-safe unless explicitly marked otherwise.
In general, you should be able to assume an IDF API is thread-safe unless explicitly marked otherwise.
Re: Thread safety
Ok, thank you.
May I suggest adding that last sentence to the docs?
May I suggest adding that last sentence to the docs?
-
- Posts: 28
- Joined: Tue Sep 10, 2019 7:22 am
Re: Thread safety
This might be a daft question, not my field of expertise. Is the same true for core safe; i.e. two threads running on different cores of the ESP32 with pre-emption in mind etc?
-
- Posts: 9770
- Joined: Thu Nov 26, 2015 4:08 am
Re: Thread safety
Yes. In general, thread safe also implies multicore threading safe on SMP systems, including the ESP32.
Who is online
Users browsing this forum: No registered users and 129 guests