Quality RTOS & Embedded Software

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




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) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists