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

Question/Suggestion for Semaphores

Posted by bodev on November 20, 2008
Hi all,
i am using a semaphore and one task and ISR communicate with that.

In my app, as suggested in FreeRTOS doc, the ISR always give the semaphore and the task always take it. however, the first interaction of the task the semaphore is already given by the creation function and not by the ISR.
This cause not correct exectution.

I noticed that in the creation (vSemaphoreCreateBinary) the semaphore is automatically "given" (xSemaphoreGive).

This problem is easily solvable by "taking" the semaphore just after creation, but it might be a good idea to have a parameter in vSemaphoreCreateBinary in order for the developer to choose if the created semapore should be given or not. or at least document this.

Am i correct? any comments?

thanks
Bo





RE: Question/Suggestion for Semaphores

Posted by Dave on November 21, 2008
Your suggestion is valid but it would have to be done in a way that was backward compatible. Maybe maintain the original function to create the semaphore and introduce a new function that has the extra parameter.

RE: Question/Suggestion for Semaphores

Posted by saiberion on November 21, 2008
by the way, what is the reason that a semaphore is given on creation?

RE: Question/Suggestion for Semaphores

Posted by Jesper Matthiesen on November 21, 2008
i wondered about that on several occasions as well.. appears more natural that it is initially "taken" i would think...

RE: Question/Suggestion for Semaphores

Posted by Martin Velek on November 23, 2008
Hi,

I was wondering too, so I replaced classic binary semaphore with counting semaphore

UARTTxBinSemaphore = xSemaphoreCreateCounting( 1, 0 );

Martin


[ 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