Menu

#89 vPortValidateInterruptPriority unnecessarily restrictive

closed
nobody
None
5
2015-03-31
2015-03-30
ilgitano
No

This is for FreeRTOS 7.5.2 for ARM Cortex M3 device. This check is not performed in FreeRTOS 7.4.0.

I have some code for a high baud rate UART which is deliberately at a higher priority than FreeRTOS critical sections. When fired, it checks if it is in an RTOS critical section using IARs __get_BASE_PRI() function, and if not it makes a call to xSemaphoreGiveFromISR(). If it IS in a critical section, it queues some information and makes the call when the critical section is left.

This code works fine on 7.4.0, and I have configASSERT enabled. On 7.5.2 if fails checks made in vPortValidateInterruptPriority (in port.c):

    /* Is the interrupt number a user defined interrupt? */
    if( ulCurrentInterrupt >= portFIRST_USER_INTERRUPT_NUMBER )
    {

I don't believe what I am doing is fundamentally wrong, and believe that the check here SHOULD at least check if the ISR is calling from a critical section:

    /* Is the interrupt number a user defined interrupt? */
    if( uxCriticalNesting > 0 && ulCurrentInterrupt >= portFIRST_USER_INTERRUPT_NUMBER )
    {

Or even further, the interrupt details are irrelevant, and just check that an ISR API call is not being made from within a critical section. The whole function I think should read:

void vPortValidateInterruptPriority( void )
{
    configASSERT( uxCriticalNesting == 0 );
}

And the assert check on portAIRCR_REG performed once only at FreeRTOS startup.

Discussion

  • ilgitano

    ilgitano - 2015-03-30

    In fact, I would like to have that as an API function, something like:

    bool SafeToCallISRAPI( void )
    {
        return  uxCriticalNesting == 0;
    }
    

    which I could use to make calls at safe times. That would be less of a hack than my use of __get_BASE_PRI to guess when FreeRTOS is in a critical section.

     

    Last edit: ilgitano 2015-03-30
  • Richard Barry

    Richard Barry - 2015-03-31
    • status: open --> closed
     

Log in to post a comment.