In a project with 4 tasks, where 2 are free running with the same priority and the other two run in function of semaphores, I noticed the following behaviour.
// Create tasks // LEDs 1 and 2 blinking at 2Hz in oposition (phase = 180º) SysCreateTask(hTaskLED1,4,Task_LED1); // Free run (LED1 follows LEDState) SysCreateTask(hTaskLED2,4,Task_LED2); // Free run (LED1 follows not LEDState) // LED 3 and 4 blink at 1Hz in quadrature ( phase = 90º) SysCreateTask(hTaskLED3,4,Task_LED3); // Wait Semaphore (LEDState 0->1) SysCreateTask(hTaskLED4,4,Task_LED4); // Wait Semaphore (LEDState 1->0) // LEDState variable and the signaling of the semaphores is all handled in the ISR***** Full project attached.*****
If the priority of tasks LED3 and LED4 are the same or higger than the priority of tasks LED1 and LED2 everything runs as expected and the all 4 LEDs flash acording to the program.
Even if one of Task LED1 and LED2 or both are not started things work as expected.
If the priority of tasks LED3 and LED4 is lower than the priority of tasks LED1 and LED2, tasks LED3 and LED4 still execute and LEDs 3 and 4 flash at 1Hz but in synch instead of in quadrature (not acording to the signaling of the semaphores).
I was expecting that tasks LED3 and LED4 will be stalled (never run) due to the higher priority of the free running tasks.
Is this some error of mine or there is a bug with the round robin algorithm that cycles the ready tasks with same priority. ?
Edited by JorgeF, 01 December 2012 - 11:59 PM.