Quality RTOS & Embedded Software

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




Loading

RTOS V3.22 Semaphore does not work properly??

Posted by Narayan on April 29, 2008
Dear all,
I have a situation which I am trying to undertand. The scenario is something like below.

I have two tasks task_A and task_B
A binary semaphore ABC is created.

task_A( )
{
A();
delay 100ticks
}

task_B( )
{
B();
delay 100ticks
}


A( )
{
if(xSemaphoreTake( ABC, portMAX_DELAY ) == pdTRUE )
{
// do something
xSemaphoreGive( ABC );
taskdelay (25 ms; //Note delay here
}
else
{
printf("Task A Error");
}
}

B( )
{
if(xSemaphoreTake( ABC, portMAX_DELAY ) == pdTRUE )
{
// do something
xSemaphoreGive( ABC ); //Note NO delay here
}
else
{
printf("Task B Error");
}
}

My setup is configured as 32bits, thereofre portMAX_DELAY will be large. However I see that I get errors "Task B Error".(and Task A error sometimes) Is it possible that the sempahore is timing out even with portMAX_DELAY or am I doing sonmething wrong here?
Any insight will be appreciated. At he moment my workaround is while ((xSemaphoreTake( ABC, portMAX_DELAY ) != pdTRUE ), but I wnat to know what is wrong.
-regards
Narayan

RE: RTOS V3.22 Semaphore does not work properly??

Posted by Richard on April 29, 2008
Its difficult to say, as you are using a rather old version (there have been 23 updates since V3.2.2!). There were some situation where a premature unblock was possible, and under certain circumstances the outer == TRUE was required, but I think this was to do with multiple tasks and interrupts accessing the same queue/semaphore. Do you have anything else accessing the semaphore, or just these tasks?

Can you update to a newer version?

Regards.


[ 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