Unblocking a Task on the "Other" Core

gfvalvo
Posts: 36
Joined: Thu Dec 24, 2020 3:06 pm

Unblocking a Task on the "Other" Core

Postby gfvalvo » Wed Jul 19, 2023 4:10 pm

Hello,

Suppose a task running on Core 0 posts some data to a FreeRTOS queue. Suppose further that a very high-priority task, that's pinned to Core 1, is currently blocked, pending on information to enter that queue.

Ideally, the high-priority task should very quickly become unblocked and preempt whatever task is currently running on Core 1 --- without needing to wait for that lower-priority task's tick time to expire. Does this happen and if so by what mechanism is Core 1 alerted to do an immediate context switch?

Thanks.

esp_programmer
Posts: 16
Joined: Wed Jul 12, 2023 4:26 am

Re: Unblocking a Task on the "Other" Core

Postby esp_programmer » Wed Jul 19, 2023 10:51 pm

Hi gfvalvo,

I was wondering this myself. For what it's worth, it appears to me that one CPU sends an interrupt to the other when a yield is needed. See taskYIELD_OTHER_CORE in tasks.c. There are registers (in the System Registers block) that allow a CPU to trigger interrupts on the other.

esp_programmer

gfvalvo
Posts: 36
Joined: Thu Dec 24, 2020 3:06 pm

Re: Unblocking a Task on the "Other" Core

Postby gfvalvo » Thu Jul 20, 2023 12:37 am

esp_programmer wrote:
Wed Jul 19, 2023 10:51 pm
Hi gfvalvo,
... See taskYIELD_OTHER_CORE in tasks.c.


@esp_programmer, thanks for the reply. Where did you find task.c? It's not in my installation, only task.h. Also there is no mention of 'taskYIELD_OTHER_CORE' in any file of my ESP32 installation.

However, I did find the following in portmacro.h. I think it pretty much answers my question.

Code: Select all

/**
 * @brief Yields the other core
 *
 * - Send an interrupt to another core in order to make the task running on it yield for a higher-priority task.
 * - Can be used to yield current core as well
 *
 * @note [refactor-todo] Put this into private macros as its only called from task.c and is not public API
 * @param coreid ID of core to yield
 */
void vPortYieldOtherCore(BaseType_t coreid);

esp_programmer
Posts: 16
Joined: Wed Jul 12, 2023 4:26 am

Re: Unblocking a Task on the "Other" Core

Postby esp_programmer » Thu Jul 20, 2023 1:21 am

Hi gfvalvo,

I am using an older version of the esp-idf (5.0). Looks like they have moved some things from tasks.c. As you noted, the function that is used is https://github.com/espressif/esp-idf/bl ... ort.c#L562 .

Thanks

Who is online

Users browsing this forum: No registered users and 49 guests