Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Problem with semaphore time

Posted by Oliver on 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
//************************************************************************************************

/
__attribute__((__noinline__))

static portBASE_TYPE eic_int_handlerPRI_NonNakedBehaviour( void )

{

portBASE_TYPE retstatus,retstatus2;

portBASE_TYPE xTaskWoken = pdFALSE;







Cont++;



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

{

F_Count_P=0;

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

calls in a critical section . */

portENTER_CRITICAL();

retstatus=xSemaphoreGiveFromISR( xSemaphoreSendP, xTaskWoken );

portEXIT_CRITICAL();

/* 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;




while(1)

{


xSemaphoreTake(xSemaphoreSendP,portMAX_DELAY);

.... // 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 ?
thanks
Oliver

RE: Problem with semaphore time

Posted by Dave on 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?

RE: Problem with semaphore time

Posted by Oliver on 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?

thanks
Oliver


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS