Derive all present threads statuses

Hello,
In my system I need to develop a Watchdog module, that monitors all created in the project threads, to check whether they are suspended or not (if suspended, the MCU will be reset). In the past I have achieved such functionality by adding a wrapper to the xTaskCreate function- each time a thread was created, I have added its ID to the global list that was available also for the watchdog.

Now, I was wondering, whether I could omit that step- is there a way (by using only FreeRTOS API) to obtain the ID’s of all created threads in the system?

RTOS - uxTaskGetSystemState() ?

Hi and thank you for answer. It seems that this is exactly what I was looking for. The only issue I would have is that the manual states:

This function is intended for debugging use only as its use results in the scheduler remaining
suspended for an extended period.

Should this not be used in production code?

It depends if you can live with the behavior of the function. It needs to do pretty much work with the scheduler being disabled to collect/snapshot all the task information.
Your initial approach is much less intrusive.

Hi there,
I have a follow up question to this:

It depends if you can live with the behavior of the function. It needs to do pretty much work with the scheduler being disabled to collect/snapshot all the task information.

By this, do you mean that the sole fact of the functionality being enabled in the system is giving the overhead already (i.e., configUSE_TRACE_FACILITY set), or is it only in the moment of function calling?

Because I was thinking to run the function just once in the beginning to collects the threads ID’s and then never do it again.

No - there is no background activity dragging down performance. It’s a single (costly) call.