Using portYIELD_FROM_ISR with STM32F4 while trigger a task on an external event

dcorreia wrote on Thursday, January 28, 2016:

I am trying to properly understand how portYIELD_FROM_ISR() works. I am having some funny behavior in my code.
Let consider the following
1.Premeption is enabled
2.I have a highest priority task waiting on a semaphore to be given. A context switch may or have occured
2.The ISR runs and portYIELD_FROM_ISR() is called because a highest prioirty task was waiting

At what point does the RTOS tell the highest priority task to run.

  1. Does the highest priority task know it has to run before the next premetive context switch
  2. Does it have to wait until another premeption event occours before the context switch can occour. Which would make it run

**Additional information **

The reason I am asking this is because my RTOS tick is 200Hz, but the interrupt that drive one of my task is 1kHz. So this task must run at 1kHz rate no exceptions.
But that task also has to wait another semaphore to be release by DMA receive interrupt. The DMA RX semaphore has timeouts but these timeouts are obvoisly reference againts the 200Hz tick interrupt. So if a context switch can only occur when a prempetion event occurs (i.e 200Hz) that means portYIELD_FROM_ISR() does not do what I intend it to do.

Some other notes

  1. The DMA RX interrupt will always run before the next 1kHz interrupt. This is guaranteed
  2. Interrupt prioirty are setup so that the RX DMA interrupt has a higher prioirty than the 1Khz interrupt…

richard_damon wrote on Friday, January 29, 2016:

An ISR calling portYIELD_FROM_ISR cause a context switch to the now highest priority ready task, in effect, making the currently running task do a yield. Basically, the timer tick in effect calls portYIELD_FROM_ISR every timer tick if time slicing is enabled or if after updating timeout timers some higher priority task is now ready to run.