Mixing pthreads support and FreeRTOS APIs

User avatar
bartvanhofwegen
Posts: 5
Joined: Mon Aug 15, 2022 5:25 pm
Location: The Netherlands

Mixing pthreads support and FreeRTOS APIs

Postby bartvanhofwegen » Thu Aug 18, 2022 12:58 pm

Hi, maybe this has been asked before but I can't find it (searching for non-trivial stuff is hard because the forum goes blank most of the time)

ESP-IDF has pthread support wrappers. Great! I have code that needs to be shared between Linux and ESP-IDF as much and as easily as possible, preferably using C++ std::thread and companions.

But is it possible to combine pthreads with some of FreeRTOS APIs such as MessageBuffers, EventGroups etc? That is: can I write to/read from a Stream/MessageBuffer, -Queue or use and EventGroup from a pthread ? I would think so since a pthread is in essence a FreeRTOS Task. Native FreeRTOS APIs are probably much more efficient than higher level constructs on top of the C++ thread API on top of the pthread support on top of FreeRTOS...

And secondly: is there a way to retrieve the Task handle for a pthread so that TaskNotifications can be used?

If so, I could write a few generic abstraction wrappers for synchronization objects and defer to the FreeRTOS ones when running on the ESP32.

Thanks in advance !
Bart

Who is online

Users browsing this forum: Baidu [Spider], egionet, kaxx1975 and 356 guests