High priority task to low priority task

for example, let’s say a task is waiting for queue and its priority is highest. Its queue is released from ISR. Now this task releases another queue to a low priority task. now do we go to that low priority task and then again come back to high priority task from where it was preemted.

you are looking for priority inheritance which is by definition only available for muteces, not generic queue objects.

priority inversion is a different thing.
Here I am not guarding a shared resource in two tasks using mutex.
I want to understand,

  • There is high priority task that’s blocked on queue.

  • Its queue is released from ISR.

  • Now this high priority task is unblocked, ready and running.

  • This high priority task releases a queue for another low priority task.

  • At this moment, does schedular goes to low priority task, low priority task runs
    and after that schedular again comes to high priority task and its start running from the line where it was preempted.

  1. At time t = t1, ISR unblocks T1 which starts running.
  2. At time t =t2, T1 unblocks T2.

Are you asking if at time t = t2, will there be a context switch? If so, no, there wont be any. The scheduler always runs the highest priority ready task and at time t = t2, the highest priority ready task is T1. T2 will only run when T1 blocks.

I’d recommend this book for learning concepts about FreeRTOS - https://www.freertos.org/fr-content-src/uploads/2018/07/161204_Mastering_the_FreeRTOS_Real_Time_Kernel-A_Hands-On_Tutorial_Guide.pdf

ok so context switch will not happen, i got it.

So lets assume what options I have, at t = t2 i want to goto Task T2 (LP). Should i call vTaskDelay().


//Queue released for Task T1 (HP)

//lets say it is Task T1 (HP)
void task_t1_v(void *parameter)
 //do some thing

 //blocking on vTaskDelay to switch to Task T2 (LP)

If ISR don’t come Task T1 will remain in block state. If ISR fires Task T1 runs.
If i block it as shown in above snippet, will schedular goes to Task T2 (LP) and comes back to T2 (HP) from where it is preempted.

You probably mean T1 (HP). Yes, the control will return to T1(HP) after 100 ticks (the time passes to vTaskDelay) has passed.

Sorry it was typo, you are correct it was T1 (HP).
Thanks for answering.

In following code snippet schedular will not do context switch at line no 100, is it?
Because T1 is HP and will remain here.

That is right. I’d again recommend the book I mentioned above.