Still using FreeRTOS (preemptive multitasking) on STM32F103VE and GCC. If I have two tasks of equal priority, both of them are blocked, and then another task gives two different samaphores, one unblocking fist task, another – unblocking second.
In which order will sheduler choose tasks to enter running state? This is essential for me, because both of these tasks are accessing shared peripheral (DMA), so if sheduler will always choose, for example, first one, then this task will block DMA, and second, after switching to it, will just block again on new semaphore. Here is an example:
xSemaphoreHandle DataSent; //New data arrives with acknoledge of success transmit,
xSemaphoreHandle NewDataArrived; //so thees two are given simultaneously
xSemaphoreHandle DMAFree; //Controls access to DMA
//....
static void taskIRQHandler(void *pvParameters) //not ISR, just high priority task
{
//...
xSemaphoreGive(DataSent);
xSemaphoreGive(NewDataArrived);
//...
}
static void taskTx()
{
//..
xSemaphoreTake(DataSent);
xSemaphoreTake(DMAFree);
//...
}
static void taskRx()
{
//..
xSemaphoreTake(NewDataArrived);
xSemaphoreTake(DMAFree);
//...
}