This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit fae075a7494848ce92703a2b9600a67da60c3ec7 Author: Tiago Medicci Serrano <tiago.medi...@espressif.com> AuthorDate: Mon Oct 23 15:40:09 2023 +0200 esp32/ble: Lock the scheduler before creating pinned thread This ensures that the thread that has been just created doesn't run before its affinity is set, avoiding it to be scheduled in the wrong CPU core. --- arch/xtensa/src/esp32/esp32_ble_adapter.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/xtensa/src/esp32/esp32_ble_adapter.c b/arch/xtensa/src/esp32/esp32_ble_adapter.c index f3232b8689..22de775e74 100644 --- a/arch/xtensa/src/esp32/esp32_ble_adapter.c +++ b/arch/xtensa/src/esp32/esp32_ble_adapter.c @@ -772,6 +772,15 @@ static int32_t esp_task_create_pinned_to_core(void *entry, DEBUGASSERT(task_handle != NULL); +#ifdef CONFIG_SMP + ret = sched_lock(); + if (ret) + { + wlerr("Failed to lock scheduler before creating pinned thread\n"); + return false; + } +#endif + pid = kthread_create(name, prio, stack_depth, entry, (char * const *)param); if (pid > 0) @@ -800,6 +809,15 @@ static int32_t esp_task_create_pinned_to_core(void *entry, wlerr("Failed to create task, error %d\n", pid); } +#ifdef CONFIG_SMP + ret = sched_unlock(); + if (ret) + { + wlerr("Failed to unlock scheduler after creating pinned thread\n"); + return false; + } +#endif + return pid > 0; }