Hi,
As far as i can determine these fields are used inconsistently and there is at least a documentation level error.
uxTCBNumber - assigned when task created.
uxTaskNumber - assigned via vTaskSetTaskNumber()
uxTaskGetTaskNumber() - claims to return uxTCBNumber in tasks.h but infact returns uxTaskNumber
vTaskGetInfo() - returns uxTCBNumber as pxTaskStatus->xTaskNumber
Agreed that will resolve the obvious error. Thanks.
I would suggest that the dual use of the term âTask Numberâ is still potential source of problems. Having had a look at the FreeRTOS-Plus-Trace library I wonder how it works. As far as I can tell it makes use of uxTaskGetTaskNumber() without corresponding use of uxTaskSetTaskNumber()
Good point. It seems that the xTaskNumber field of the TaskStatus_t struct is unfortunately named. The caller of vTaskGetInfo() would need to be careful not to expect the xTaskNumber field to match the return value of uxTaskGetTaskNumber().
I couldnât immediately see the problem you refer to in +Trace. The user of the +Trace library has the option to use the task number but does not have to do so. As you say, if they actually use it, they would need to call vTaskSetTaskNumber() if they have expect uxTaskGetTaskNumber() to return something meaningful.
You say they have the option to use it but it seems to be embedded in the +Trace library.
UxTaskGetTaskNumber called by prvTraceGetTaskNumberLow(|High)16
prvTraceGetTaskNumberLow16 used by TRACE_GET_TASK_NUMBER
TRACE_GET_TASK_NUMBER called in many places e.g.
trcKERNEL_HOOKS_TASK_SWITCH which passes it to prvTraceStoreTaskswitch()
uiTraceStart()
vTaskSetTaskNumber called by prvTraceSetTaskNumberLow(|High)16
prvTraceSetTaskNumberLow16 is only used by TRACE_SET_TASK_NUMBER
TRACE_SET_TASK_NUMBER is not automatically used anywhere.
Therefore without the user putting in explicit calls to UxTaskSetTaskNumber or TRACE_SET_TASK_NUMBER for each of their threads the underlying pxTCBâuxTaskNumber will be 0. I canât find evidence of this in any of the Demo projects .
Iâve not currently got the TraceAnalyser tool to look at the data recorded, e.g. by the Posix_GCC Demo to see what an end user would see.
Disappearing down a rabbit hole, Iâm obviously missing or failing to appreciate something basicâŚ
I suspect the Tracealyzer UI doesnât âneedâ the task number at all, but maybe the UI can show the number if the user wants to see it. In that case the userâs own application code would be setting the task number. I donât have Tracealyzer anymore so canât check.
We are using TaskNumber in Tracealyzer for trace filtering. Only used in the snapshot recorder . We do use vTaskSetTaskNumber() when a task is created. It is done by some macro magic: #define TRACE_SET_OBJECT_NUMBER(CLASS, pxObject) TRACE_SET_##CLASS##_NUMBER(pxObject)
Here is an example in a debugger after a task is created:
We take the TCBnumber and add 0x10000.