Perhaps I do not understand something about the way FreeRTOS works, but I am surprised about the time it takes the scheduler to respond to xTaskResumeFromISR(). I also tried using Semaphores, but result was the same. I am running FreeRTOS-5.2 with PREEMPTION enabled, also configIDLE_SHOULD_YIELD, Mutex,Coroutines,Sem off. MCU is ARM7 LPC2468 (72MHz). My tick time is 10mSec. The CPU spends 98% of time in the IDLE task.
I have 3 tasks besides IDLE, and two have prioity 1 and the other has priority 4. There is a wrapped ISR. The PRI-4 task waits suspended. At the end of this ISR I call xTaskResumeFromISR() to release the PRI-4 task. I expected that as soon as the ISR returns the scheduler would instantly do a switch to the PRI-4 task. It does the switch fine, but it appears to be taking a lot of time.
I placed uSec performance time markers at the end of the ISR and right after vTaskSuspend()in the PRI-4 task. It appears that the scheduler is taking between 3-7 mSec to switch to the PRI-4 task. This I do not understand. I expected something on the order of 10’s or 100’s of uSec.
I expected that the scheduler should leave the IDLE task immediately and jump into PRI-4. But it seems like it is waiting until the end of the tick time slice before it switches. That’s the only explanation I can see for the big delay. Is this correct?