I’m using the FreeRTOS v5.0.0 with a PIC18 mcu and the MPLAB building toolchain.
I have two tasks, with the same priority (tskIDLE_PRIORITY + 1). Task T1 sends a message every two seconds (using vTaskDelayUntil) to a Queue and Task T2 receives this message from the Queue using a blocking xQueueReceive (meaning porTMAX_DELAY is used as blocking time and vTaskSuspend support is enabled) and sends it over the serial.
System hangs for some reason Monitoring what happens the execution sequence until system stops is:
1) T2 starts execution and blocks waiting for a message to arrive at the Queue
2) T1 starts execution, successfully waits for two seconds and then calls XQueueSend
System is hanged!
I’ve pinpointed the problem on using taskYIELD() inside the critical section of xQueueGenericSend(). When T2 is removed from the event list, xTaskRemoveFromEventList() returns pdTRUE because both tasks have the same priority (it’s supposed to return true if the unblocked task has higher priority but it works the same way for equal priorities too). The taskYIELD() following for some reasons fails. Any ideas? I’m still looking out why this is happening. If I comment out taskYIELD() everything works fine.