How does FreeRTOS determine Task Numbers.

How does freeRTOS assign Task numbers? ~~~ synctask_ R 1 1769 11 inittask R 1 1564 1 IDLE R 0 485 2 Tmr Svc B 2 972 3 othertas B 1 406 4 changesy B 3 981 10 button B 1 467 9 ~~~ Why do I not see task numbers 5, 6, 7 and 8?

How does FreeRTOS determine Task Numbers.

The task number is just incremented every time a task is created. If there are numbers missing then I’m assuming those tasks have been deleted. The task number allows you to uniquely identify a task. For example, if you create a task then the handle for the task is effectively a pointer to the task’s TCB (although opaque, so it cannot be decoded as such). If you delete the task then the TCB will be freed, and if using dynamic memory allocation, the memory will be returned to the heap. If you then create another task it is likely that the same memory will be used to store the newly created task’s TCB. So the handle of the old task and the handle of the new task will be the same – even though its a different task. Therefore, if there is a chance this will happen in your application, and when it does its essential your application knows, then you check the task number too. This is currently mainly used by task aware debuggers.