FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [November 2013 Threads] vSemaphoreCreateBinaryPosted 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
}
}
vSemaphoreCreateBinaryPosted 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.
vSemaphoreCreateBinaryPosted 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.
vSemaphoreCreateBinaryPosted by *anonymous on November 13, 2013 Yes, the error was in my configTOTALHEAPSIZE i increased heap size problem solved. Thank you so much :-)
vSemaphoreCreateBinaryPosted 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?
vSemaphoreCreateBinaryPosted 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.
vSemaphoreCreateBinaryPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|