Esp32 Task concurrent problems

huang.yan
Posts: 17
Joined: Thu Apr 09, 2020 12:26 pm

Esp32 Task concurrent problems

Postby huang.yan » Tue May 05, 2020 6:13 am

There are two cpu cores in esp32.I have a few questions about esp-idf task.

1.when two task running by each core calling uart_write_bytes() at the same time,will it cause data disorder or loss? Is uart_write_bytes() task/thread safe?

2. A while(1){ do something} loop in app_main,is this loop running by pro core or both core ?

3. Callback funtion set by esp_wifi_set_promiscuous_rx_cb() running by pro core or both core ?

Thanks.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Esp32 Task concurrent problems

Postby ESP_igrr » Wed May 06, 2020 6:12 am

huang.yan wrote: 1.when two task running by each core calling uart_write_bytes() at the same time,will it cause data disorder or loss? Is uart_write_bytes() task/thread safe?
uart_write_bytes is thread safe, but however if you see any issue with it you could also wrap the call to this function in a mutex.
huang.yan wrote: 2. A while(1){ do something} loop in app_main,is this loop running by pro core or both core ?
app_main runs from the "main" task, which is pinned to CPU 0 (PRO CPU)
huang.yan wrote: 3. Callback funtion set by esp_wifi_set_promiscuous_rx_cb() running by pro core or both core ?
This callback gets dispatched from the wifi task. It is possible to configure Wi-Fi task affinity in menuconfig (CONFIG_ESP32_WIFI_TASK_CORE_ID): either CPU0, or CPU1, or no affinity.

huang.yan
Posts: 17
Joined: Thu Apr 09, 2020 12:26 pm

Re: Esp32 Task concurrent problems

Postby huang.yan » Wed May 06, 2020 6:40 am

Thanks,these answers help me a lot.

Who is online

Users browsing this forum: Bing [Bot] and 88 guests