void forward(void *pvparam)
{
while(1)
{
if(xSemaphoreTake(xSemaphore,1000)==pdTRUE)
{
UART0_SendStr("Frwd took it\n");
}
else
{
UART0_SendStr("Frwd couldn't take it\n");
}
vTaskDelay(1000);
}
}
void back(void *pvparam)
{
vTaskDelay(100);
while(1)
{
if(xSemaphoreGive(xSemaphore)==pdTRUE)
{
UART0_SendStr("Back Gave it:MF\n");
}
else
{
UART0_SendStr("Back couldn't give it:MS\n");
}
vTaskDelay(1000);
}
}
Above code is the one which i am using for both Binary semaphore and Mutex. The only difference is for binary semaphore i am writing "xSemaphoreCreateBinary(xsemaphore);" in main and for mutex xSemaphoreCreateMutex(xsemaphore) in main.
According to the definetion
"A semaphore(Mutex) occupied by the task can only be given by that Task and the Semaphore(Binary) created by a Task can be given by any of the Tasks"
But both the codes(i.e for binary semaphore and mutex) are giving same output.