dberenguer wrote on Monday, July 20, 2009:
I’ve created a simple semaphore mutex into one of the tasks in order to avoid silmultaneous access to a global variable. The code is identical to the one explained in the online tutorial:
xSemaphoreHandle xSemaphore = NULL;
void myTask(void *pvParameters)
{
xSemaphore = xSemaphoreCreateMutex();
…
}
void myfunction(void)
{
…
if( xSemaphoreTake( xSemaphore, ( portTickType ) 10 ) == pdTRUE )
{
// Access to the global resource
xSemaphoreGive(epSemaphore);
}
…
}
…
I’ve verified that the semaphore is correctly created. During the first accesses, it’s even “taken” and “released” without problems. However, after some successful accesses, myfunction gets blocked at xSemaphoreTake. Doing xBlockTime = 0 solves the problem but I’d like myfunction to wait at least some ticks before abandoning the semaphore. I’m thinking that maybe FreeRTOS doesn’t know what a tick is in my system so that it waits indefinitely. I’ve maybe missed some definition elsewhere…
I understand that my descriptions are quite vague but… has anyone an idea about what could be happening with my setup?
Thank you very much,
Daniel.