FreeRtos context switch

If higher priority task is waiting for an event and lower priority task is running. Before tick interrupt higher priority task gets ready then how context switch will happen before tick interrupt? Till tick interrupt higher priority task will be waiting for tick interrupt to context switch?

I need to know that in freertos context switch happen only at tick interrupt? If it is not then how higher priority task preempt the lower priority task before tick interrupt, if it get ready before tick interrupt?

[Moved to Kernel category]

If configUSE_PREEMPTION is set to 1 in FreeRTOSConfig.h then FreeRTOS will always run the highest priority task that is able to run even if a task becomes available to run in between tick interrupts. This happens because sending an event that unblocks a task requires you to call a FreeRTOS API function, and the context switch happens in the API function. I would recommend reading the free book to learn more about the scheduling policy.

Hi @skdbyte. Welcome to the new forums. We moved your post from the Percepio category to the kernel category for you since this post was most appropriate as a kernel specific topic.

As per you, if lower priority task running and holding a semaphore while for same semaphore higher priority task waiting to free this semaphore.
So whenever lower priorirty task call xSemaphoreRelease(), this function call context switch API if any higher priorty waiting for this semaphore.
Did I get correctly?

Yes. There are lots of avenues to finding this information. I already provided a link to the book. The website also provide a lot of good information, and you can look at the source code for the function of interest and even step through the code using the Windows port to see how it operates.