freertos: Adds new APIs to set/get and restore base priority

Closes https://github.com/espressif/esp-idf/issues/7580
This commit is contained in:
KonstantinKondrashov
2022-07-14 00:28:59 +08:00
parent 9e863ecdb8
commit e8bf8ce14d
9 changed files with 319 additions and 6 deletions

View File

@@ -11,6 +11,7 @@
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/idf_additions.h>
#include <freertos/semphr.h>
#if CONFIG_IDF_TARGET_ESP32
#include "soc/dport_reg.h"
@@ -150,8 +151,9 @@ void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu(void)
} else {
// Temporarily raise current task priority to prevent a deadlock while
// waiting for IPC task to start on the other CPU
int old_prio = uxTaskPriorityGet(NULL);
vTaskPrioritySet(NULL, configMAX_PRIORITIES - 1);
prvTaskSavedPriority_t SavedPriority;
prvTaskPriorityRaise(&SavedPriority, configMAX_PRIORITIES - 1);
// Signal to the spi_flash_op_block_task on the other CPU that we need it to
// disable cache there and block other tasks from executing.
s_flash_op_can_start = false;
@@ -164,7 +166,7 @@ void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu(void)
// Disable scheduler on the current CPU
vTaskSuspendAll();
// Can now set the priority back to the normal one
vTaskPrioritySet(NULL, old_prio);
prvTaskPriorityRestore(&SavedPriority);
// This is guaranteed to run on CPU <cpuid> because the other CPU is now
// occupied by highest priority task
assert(xPortGetCoreID() == cpuid);