Hi,
Typically there is code like that in an ISR:
void vSoftwareInterruptHandler( void )
{
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
/* 'Give' the semaphore to unblock the task. */
xSemaphoreGiveFromISR( xBinarySemaphore, &xHigherPriorityTaskWoken );
/* Clear the software interrupt bit using the interrupt controllers
Clear Pending register. */
mainCLEAR_INTERRUPT();
/* Giving the semaphore may have unblocked a task - if it did and the
unblocked task has a priority equal to or above the currently executing
task then xHigherPriorityTaskWoken will have been set to pdTRUE and
portEND_SWITCHING_ISR() will force a context switch to the newly unblocked
higher priority task.
NOTE: The syntax for forcing a context switch within an ISR varies between
FreeRTOS ports. The portEND_SWITCHING_ISR() macro is provided as part of
the Cortex M3 port layer for this purpose. taskYIELD() must never be called
from an ISR! */
if (xHigherPriorityTaskWoken!=pdFALSE)
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
}
This strikes me a bit as odd since I would assume that the default behaviour that most people want is to enforce a context switch after the ISR to the higher priority task which was awoken by the ISR.
Why isn’t this the default behavior and we need to do all this extra calls explicitly?
What would be a valid reason to wait for the next context switch to switch to the highest priority task instead of making this the default behaviour?
Regards,
Robert