Hello!
I have read the comment in function vListInsert()
. But it’s a bit tricky to troubleshoot.
The bug happens when the execution flow is as follow:
(1) semaphore ‘sem’ is created by thread func
and initialized as 0
(2) Thread func
called xSemaphoreTake()
to block and wait infinitely for the semaphore sem
(3) In the for(;;)
loops, when it calls prvLockQueue()
and enter the vTaskPlaceOnEventList()
, an interrupt comes simultaneously. The interrupt handler called “xSemaphoreGiveFromISR()” , and then “portYIELD_FROM_ISR()” if pxHigherPriorityTaskWoken
is set to true. The semaphore is released.
(4) Thread func
entered vListInsert()
and stucked.
If the semephore is released by the IRQ handler before prvLockQueue()
being called, this bug doesn’t happen.
I’m stuck on this problem and I‘m not sure where to start with. Does anyone have any ideas?
Thank you for your time!