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

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) 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