How do I find the task state?

jorick23 wrote on Tuesday, March 04, 2008:

Given a task handle, I need to find the state of a task; either Ready, Blocked, or Suspended.  How do I do that?  I don’t see a function for that.

maxim79 wrote on Tuesday, March 04, 2008:

> Given a task handle, I need to find the state of a task; either Ready, Blocked, or Suspended.
> I don’t see a function for that.

FreeRTOS doesn’t provide such a function.

> How do I do that?

Keep tracking of what you’re programming. If the task is executed it is in ready/run state. If you call vTaskDelay() it switches to blocked state for number of ticks. If you call vTaskSuspend() the task is in state suspended.

rtel wrote on Tuesday, March 04, 2008:

You could implement such a function but it would not be particularly quick.  The list from which a task is referenced denotes the tasks state, and as references are bidirectional it is straightforward to find the list.  Look at the function vTaskList() for some clues - this prints out information on each task, including the state of the task.

Regards.

jorick23 wrote on Tuesday, March 04, 2008:

All of the lists are static.  I can’t access them from outside of the tasks.c module.  Is there a global way to access the lists?

rtel wrote on Tuesday, March 04, 2008:

There is no global way of accessing the lists - that is intentional.  You can add functions to tasks.c to access the lists.

Regards.