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

vSemaphoreCreateBinary

Posted by *anonymous on November 13, 2013

I have two Binary semaphores its not working simultaneously here if i comment vReadtask vCriticalTask will execute and if comment vCriticalTask , vReadtask will execute i cant use both simultaneously. What could be the reason? please help

vSemaphoreCreateBinary( xBinarySemaphore ); vSemaphoreCreateBinary( xReadSemaphore );

and two tasks

xTaskCreate( vReadTask, "Handler", MEDIUMSTACKSIZE, NULL, 11, &xReadHandler); xTaskCreate(vCriticalTask,"Critical", MEDIUMSTACKSIZE,NULL,12,&xCriticalHandle);

void vReadTask( void *pvParameters ) { for( ;; ) { xSemaphoreTake( xReadSemaphore, portMAX_DELAY );

     //read code
}

}

void vCriticalTask( void *pvParameters ) { for( ;; ) { xSemaphoreTake( xBinarySemaphore, portMAX_DELAY ); //critical code } }


vSemaphoreCreateBinary

Posted by richard_damon on November 13, 2013

Not seeing the SemaphoreGive code, the only problems that I can see is you might be running out of heap.

What exactly do you comment out to make one side to work.


vSemaphoreCreateBinary

Posted by *anonymous on November 13, 2013

I have many tasks in my program all others are work fine. The problem is in these two tasks, i can use either one of this task SemaphoreGive() using some other tasks, i comment the create task ////xTaskCreate( vReadTask, "Handler", MEDIUMSTACKSIZE, NULL, 11, &xReadHandler);

xTaskCreate(vCriticalTask,"Critical", MEDIUMSTACKSIZE,NULL,12,&xCriticalHandle);

this time CriticalTask will work

xTaskCreate( vReadTask, "Handler", MEDIUMSTACKSIZE, NULL, 11, &xReadHandler);

///xTaskCreate(vCriticalTask,"Critical",MEDIUMSTACKSIZE,NULL,12,&xCriticalHandle;

this time ReadTask will work.


vSemaphoreCreateBinary

Posted by *anonymous on November 13, 2013

Yes, the error was in my configTOTALHEAPSIZE i increased heap size problem solved. Thank you so much :-)


vSemaphoreCreateBinary

Posted by *anonymous on November 13, 2013

void vReadTask( void *pvParameters ) { for( ;; ) { xSemaphoreTake( xReadSemaphore, portMAX_DELAY ); //read code } }

Here the read code will execute first time (program starting) before giving a semaphore. why this happening? how to avoid this?


vSemaphoreCreateBinary

Posted by davedoors on November 13, 2013

Look at the vSemaphoreCreateBinary() definition in semphr.h. You will see it is given after it is created so the first take will pass. If you don't want that then take the semaphore straight after you have created it, before you use it in your task.


vSemaphoreCreateBinary

Posted by richardbarry on November 13, 2013

The head revision in SVN currently has a new xSemaphoreCreateBinary() function that works like all the other semaphore create function (a function that returns the semaphore) so the vSemaphoreCreateBinary() macro (note with a 'v' prefix) can be retired - although it will remain in the source code for backward compatibility. The 'x' version creates an empty semaphore, so a 'give' must be performed before a 'take' will pass.

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