Howto find a blocked task's whereabouts?

vespaman2 wrote on Monday, May 23, 2011:

Is there a way to parse the task stack to get to know where a particular task is at a given state?

I have a task that  stops executing (comes up as blocked in the task list), and I need to know why/on what it is waiting.

I guess this can be done with the stateviewer, but afaict, I don’t have the correct (supported) eclipse environment for stateviewer. (I am using CodeSourcery GCC on Coldfire V2).

davedoors wrote on Monday, May 23, 2011:

The task stack can be inspected, but how things are placed on the stack is very port dependent. You will have to look at the compiler and CPU manuals or the portSAVE_CONTEXT() definition to see where the program counter is saved.

Another option is to use the trace macros to record what that task is doing. You can define the trace macro so it only records information when the pxCurrentTCB is equal to the handle of the task you are interested in.

vespaman2 wrote on Monday, May 23, 2011:

Trace macros may be a way forward (thanks, I have not thought about that!) but as this only happens ever so often, so ideally for me, a post-mortem solution is the preferred way forward here.

There’s no other way to know, maybe from the os point of view, what a particular task is blocking on?


davedoors wrote on Monday, May 23, 2011:

If the task is blocked on a queue or semaphore then the state viewer will give you the queue or semaphore handle, and then you can cross check the handle in the state viewer to get the queue or semaphore name (if the queue or semaphore has been registered).