dspaude wrote on Wednesday, October 10, 2007:
I have found a problem where my system is missing the execution of a task due to missing the signaling of a semaphore that would allow the task to continue. Per suggestions on this forum I am using semaphores for all of my interrupts because resuming/suspending isn’t the best for events that may trigger while the task is executing. So, in my interrupt service routine I call xSemaphoreGiveFromISR() with the semaphore queue handle and in the task I wait for the semaphore using xSemaphoreTake() with portMAX_DELAY.
Here is what I see when the system is idle or under light load where I get an interrupt every 16 ms:
[00, 00:01:41.645] xhfc_ISR (interrupt event)
[00, 00:01:41.645] xhfc_ISR: S_XHFC (semaphore signaled from ISR)
[00, 00:01:41.645] ** ENTER XHFC ** (task receives semaphore signal)
[00, 00:01:41.645] ** EXIT XHFC ** (task waits for another semaphore)
[00, 00:01:41.660] xhfc_ISR
[00, 00:01:41.660] xhfc_ISR: S_XHFC
[00, 00:01:41.660] ** ENTER XHFC **
[00, 00:01:41.660] ** EXIT XHFC **
[00, 00:01:41.675] xhfc_ISR
[00, 00:01:41.675] xhfc_ISR: S_XHFC
[00, 00:01:41.675] ** ENTER XHFC **
[00, 00:01:41.675] ** EXIT XHFC **
[00, 00:01:41.690] xhfc_ISR
[00, 00:01:41.690] xhfc_ISR: S_XHFC
[00, 00:01:41.690] ** ENTER XHFC **
[00, 00:01:41.690] ** EXIT XHFC **
…
However, under load this is what I see (interrupt is still every 16 ms):
[00, 00:01:41.995] xhfc_ISR
[00, 00:01:41.995] xhfc_ISR: S_XHFC
[00, 00:01:41.995] ** ENTER XHFC **
[00, 00:01:41.995] ** EXIT XHFC **
[00, 00:01:42.010] xhfc_ISR
[00, 00:01:42.010] xhfc_ISR: S_XHFC
[00, 00:01:42.025] xhfc_ISR
[00, 00:01:42.025] xhfc_ISR: S_XHFC
[00, 00:01:42.030] ** ENTER XHFC **
…
The OS missed executing the task which in my case causes a receiver overrun. There is only one task that has the same priority as this task and that task is not receiving much data. However, there are many other lower-priority tasks that are very busy.
I am using the 4.5.0 version of FreeRTOS and I am going to try 4.4.0 because I noticed there were some changes to the semaphore/queue code. Any other tips are appreciated, though.