This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Restarting a stuck task

We have a task that gets stuck sometimes. We want to detect this case (watchdog?) and restart the task. What is the best way to achieve this? 

Thanks.

  • Stuck on what? If it's a
    - Semaphore_pend/Event_pend/Mailbox_pend/Mailbox_post/Task_sleep: you need to supply a better timeout

  • Unfortunately we haven't been able to attach a debugger when this happens, all we know is the task no longer executes. This happens only when the device is in an airborne state.

    Is there a way to capture the reason a task is blocked programmatically and save it to memory to analyze later?
  • pixbroker said:
    Is there a way to capture the reason a task is blocked programmatically and save it to memory to analyze later?

    SYS/BIOS uses an XDC module named Log:

    Among other things, Log captures Task scheduling events.  There are many types of Log events that can be turned on/off.  You view LOG events using the ROV tool in CCS.  You can attach a debugger after-the-fact and capture/view the Log events.

    Log calls down to a Logger to do the actual work of storing the event.  A Logger might have a fixed buffer that can fill up and wrap around, overwriting the oldest events.  If you store the handle of your Logger then you can disable that Logger at any point, such as a point at which you detect that a Task is stuck.

    Please follow the link I provided above to discover more about Log and Logger.

    Regards,

    - Rob

  • pixbroker said:
    We have a task that gets stuck sometimes. We want to detect this case (watchdog?) and restart the task. What is the best way to achieve this?

    The only way to restart a Task is to delete it with Task_delete() and then recreate it with Task_create().

    I'm not sure if you're asking about this, but as for detecting a stuck task, only the application writer can know if a Task is stuck (vs just being blocked for a long time).

    Regards,

    - Rob