Problem with semaphore time

gary10es wrote on Monday, December 14, 2009:

Hello everybody, i have a problem with the time in communicate my interrupt and one task while a semaphore.
My tick is 1mseg, and the frecuency of my micro in EVK1100 is 66Mhz.

the code is that


static portBASE_TYPE eic_int_handlerPRI_NonNakedBehaviour( void )


portBASE_TYPE retstatus,retstatus2;

portBASE_TYPE xTaskWoken = pdFALSE;


if ( (F_Count_P==1) && (-Num_Execute_P==0))



/* Because FreeRTOS is not supposed to run with nested interrupts, put all OS

    calls in a critical section . */


retstatus=xSemaphoreGiveFromISR( xSemaphoreSendP, xTaskWoken );


/* The return value will be used by portEXIT_SWITCHING_ISR() to know if it

       should perform a vTaskSwitchContext(). */

        if (retstatus)
  xTaskWoken = pdTRUE;


/* The return value will be used by portEXIT_SWITCHING_ISR() to know if it

       should perform a vTaskSwitchContext(). */

    // False because don’t change the task when the interrupt happened.!!!!!!

    //Reset the Interrupt

eic_clear_interrupt_line(&AVR32_EIC, EXT_INT0);

return (xTaskWoken);


and the task to unblock with this semaphore is this:
static portTASK_FUNCTION( vTxRxPCUTask, pvParameters )


const portTickType xTicksToWait=TIMEOUT/portTICK_RATE_MS; //Ponemos el timeout en mseg como cte.Se aplica a todos

unsigned short i,j;

unsigned short length_aux;

_dataword aux;

_datadoubleword aux2;

( void ) pvParameters;




          …. // rest of code

the time beetwen the semaphoreGive and the semaphore Take is about 70 microsecond, and i want to reduce this time

is there any possibilitty? need i use co-routine? can i use a flag in the interrupt  and the task every moment see the flag ?

any idea ?

davedoors wrote on Tuesday, December 15, 2009:

I’m not sure what the effect of the critical section in the interrupt will be. Probably bad at a guess though as the macros used will be using variables that are part of the task context.

Make sure the task you want to wake is the highest priority to ensure it runs as soon as its unblocked. Are you context switching to it before leaving the interrupt?

gary10es wrote on Wednesday, December 16, 2009:

hello, this task is the highest priority, but when the interrupt awaken i not sure if need to change the context, because in that moment should all task are in blocking state.  I´ll check   retstatus=xSemaphoreGiveFromISR( xSemaphoreSendP, xTaskWoken );   retstatus because the value can be true.
Two question:

a) How can i do that this task run as soon as its unblocked?
b) And what can i do to avoid context switching?