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
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”, MEDIUM_STACK_SIZE, NULL, 11, &xReadHandler);
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.
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.