Page 1 of 1

Esp32 Task concurrent problems

Posted: Tue May 05, 2020 6:13 am
by huang.yan
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.

Re: Esp32 Task concurrent problems

Posted: Wed May 06, 2020 6:12 am
by ESP_igrr
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.

Re: Esp32 Task concurrent problems

Posted: Wed May 06, 2020 6:40 am
by huang.yan
Thanks,these answers help me a lot.