FreeRTOS v10.2.1 creating the last task again

bdouram wrote on Monday, October 14, 2019:

Hi,
I’m a beginner in FreeRTOS plaftorm , developing it in a Cortex-M4 and i have a trouble.

I used some macro traces avaliable here: https://www.freertos.org/rtos-trace-macros.html, and i build a buffer to see in Cortex the time of context switching.

I have two tasks," A" and “B”.

void prvSetupTasks()
{
	xTaskCreate(taskA, TASK_A_NAME, configMINIMAL_STACK_SIZE, NULL, TASK_A_PRIORITY, &xTaskA);
	xTaskCreate(taskB, TASK_B_NAME, configMINIMAL_STACK_SIZE, NULL, TASK_B_PRIORITY, &xTaskB);
}

When i use the macro traceTASK_CREATE(xTask) to look the timestamps, the order of creation is:

“A” task created.
“B” task created.
“B” task created again.
Scheduler Task Created.
[…]

Is this right?

Thank you!

rtel wrote on Monday, October 14, 2019:

Does not look right. Are those the only two tasks you are creating in
your system? Could it be third task is the idle or timer task being
created? Are you sure it is not your implementation of the macro that
is causing confusion? Put a break point in the implementation to see
where it is getting called from and exactly what it is doing.

bdouram wrote on Monday, October 14, 2019:

Hi Richard

Thanks for your response. I saw that in fact the new task being created is the idle thread, however, in debugging, inside the traceTASK_CREATE (xTask) macro, the name that is in pxCurrentTCB-> pcTaskName when creating the idle thread is the name of the task "B "and not idle thread or something.

Tasks are created only once before scheduler execution, just as I presented above. Please, is there any way to know that task “B” is being created only once and not twice?

Thanks again.

rtel wrote on Tuesday, October 15, 2019:

You can use https://www.freertos.org/a00021.html#usTaskGetNumberOfTasks
to see how many tasks are created, or
https://www.freertos.org/uxTaskGetSystemState.html to get details on
each task in the system. Alternatively, depending on your IDE, you can
view task information in a FreeRTOS aware IDE plug-in.

bdouram wrote on Tuesday, October 15, 2019:

It works! Thanks!