seagull_kamome wrote on Friday, June 15, 2018:
I guess that my previous post got filtered. So, this is second post.
Hi FreeRTOS developer team.
I’m currently testing FreeRTOS kernel for our project. And, found
something weird.
xStreamBufferReset doesn’t save a STATICALLY_ALLOCATED flag in ucFlags. So,
it will crashes our system at vStreamBufferDelete by calling free().
2.
xSemaphoreGet with Mutex doesn’t give priority back to that mutex holder
when timed out
Sorry. I can’t explain well in english so I’ll show the unit test code.
Task1
static SemaphoreHandle_t mx1;
static unsigned int volatile test_counter;
static TaskHandle_t test_task;
static void test_task_main_1(void* args __unused) {
xSemaphoreTake(mx1, 10); // will be fail.
++test_counter;
ulTaskNotifyTake(0, portMAX_DELAY);
++test_counter;
xSemaphoreTake(mx1, portMAX_DELAY);
++test_counter;
ulTaskNotifyTake(0, portMAX_DELAY);
++test_counter;
xSemaphoreGive(mx1);
vTaskDelete(NULL);
}
and test task. This task has priority (tskIDLE_PRIORITY + 2).
should_eq(xTaskGetCurrentTaskHandle(), xSemaphoreGetMutexHolder(mx1)); //
precondition check
should_eq(tskIDLE_PRIORITY + 2, uxTaskPriorityGet(NULL)); // precondition
check
test_counter = 0;
should_eq(pdTRUE, xTaskCreate(test_task_main_1, “TSK”,
configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 3, &test_task));
should_eq(tskIDLE_PRIORITY + 3, uxTaskPriorityGet(NULL)); // OK. the
priority is inherited.
should_eq(0, test_counter); // OK. the task still waiting.
vTaskDelay(11);
should_eq(1, test_counter); // OK. the task already timed out
// All tests is OK until here.
// BUG? FreeRTOS never descent priority into base when the waiting task
got timeout.
should_eq(tskIDLE_PRIORITY + 2, uxTaskPriorityGet(NULL)); // Fail: actual
is tskIDLE_PRIORITY + 3
xTaskNotifyGive(test_task); // elevate again. the task will preempt control.
taskYIELD(); // but actually not.
should_eq(2, test_counter); // OK. the task waiting again.
should_eq(tskIDLE_PRIORITY + 3, uxTaskPriorityGet(NULL)); // OK
should_eq(pdTRUE, xSemaphoreGive(mx1)); // OK
should_eq(3, test_counter); // OK
should_eq(test_task, xSemaphoreGetMutexHolder(mx1)); // OK
should_eq(tskIDLE_PRIORITY + 2, uxTaskPriorityGet(NULL)); // Fail:! I’m
still in tskIDLE_PRIORITY + 3!!!
Thanks