Restart task from begining without deleting it?

I have a static task and a watchdog task that keeps track of all tasks. ~~~ void vTask1() { //Entry point here
StartWatchdog();

//Some function hangs
foo();

//Never reaches here
FeedWatchdog();
} ~~~ Start the watchdog task and for each task there is a count down variable. If a task has a function that hangs and takes a lot of CPU cycles then the task can’t feed/reset the watchdog count down. Then the watchdog task will be notified of the task hanging. What is the best way to go from foo() to the entry point if a task hangs? Is it deleting the task with vTaskDelete() and then using xTaskCreateStatic() again?

Restart task from begining without deleting it?

What is the best way to go from foo() to the entry point if a task hangs? Is it deleting the task with vTaskDelete() and then using xTaskCreateStatic() again?
That is up to you. I would find it too complicated to restart / restore everything, and rather choose for a CPU reset. A possible solution is the following: when a task turns out to be hanging, enable the hardware watchdog (WDT) and let it expire as quickly as possible. The CPU will get a reset, and make sure that after rebooting the WDT is not re-enabled. Unless you want to use it, of course. Also I would store some debug information at a certain place in flash. Store the value of LR of each process, to see where they were hanging out. Regards.

Restart task from begining without deleting it?

That is definitely the cleanest way. Other options would be to place an outer loop in the implementation of your task, so the offending task can ‘break’ out of the normally infinite loop, then go back to the start of the outer loop. Another but more cumbersome option would be for the task use xTimerPendFunctionCall() (http://www.freertos.org/xTimerPendFunctionCall.html ) to pend a function that deletes then re-creates it.

Restart task from begining without deleting it?

One thing to point out that arbitrarily restarting a task is often a very bad thing, as there will be no cleanup of resources for that task (It isn’t like aborting a process on a big OS, where the OS tracks most resources and automatically frees them when a process terminates). You can set a flag that the task checks frequently, and when it sees it, it can then clean up for itself and restart. If it is unable to do that, then unless you know a lot of details about the state of that task, just resetting the task tends to cause issues, and the real solution tends to be you need to reset the full system. (The right solution would be add the needed error checks/time outs to the task to keep it from misbehaving in this way).