Quality RTOS & Embedded Software

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


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


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 ?

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?


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

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

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

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

Xilinx Microblaze and Zynq partner