What is the meaning of the global variable uxTaskNumber?

I’m just starting to learn freertos, can anyone tell me what about the variable uxTaskNumber does?

PRIVILEGED_DATA static UBaseType_t uxTaskNumber = ( UBaseType_t ) 0U;

void vTaskDelete( TaskHandle_t xTaskToDelete )
    uxTaskNumber++;//  why?

Note, its static, so you can’t access it from code outside task.c. If I remember right, it is a counter for how many tasks have been created and each task gets assigned a unique number as this gets incremented as tasks are created.

As the comment just before that statement in the code says, it also gets incremented in vTaskDelete as a flag that the task list just changed. Since the number isn’t actually used for anything inside FreeRTOS itself, skipping numbers isn’t an issue (and in my mind deleting tasks is a somewhat rare action anyway).

There are a couple of there. One allows FreeRTOS aware debuggers to uniquely identify tasks. If a task gets deleted, then re-created using the same memory, that task number will be different so the debugger knows its a different task. The other is for manipulation by trace code built into the executable.

    #if ( configUSE_TRACE_FACILITY == 1 )
        UBaseType_t uxTCBNumber;  /*< Stores a number that increments each time a TCB is created.  It allows debuggers to determine when a task has been deleted and then recreated. */
        UBaseType_t uxTaskNumber; /*< Stores a number specifically for use by third party trace code. */