Is there a way to reset = restart a task?

Hello FreeRTOS team,
I wonder if there is a way to restart a task. I couldn’t find anything in the ref man.
I think it should be possible, the task function is there and the stack address also, so both could be reset. Did I miss something?
Thanks for any help
Martin

You can delete a task and re-create it which would essentially restart it. Why do you want to do it though? What is the problem that you are trying to solve?

That’s not good news as I am working with static tasks only.
I have one task that starts actions in other tasks and then waits for completion. If something fails in one of these tasks also the calling task will hang. I can use a timeout, but what to do then? I don’t have deep information in the calling task about things going on in the hanging task and even if so could not fix it. So one solution seems to be to reset the hanging task which would reinitialise related software, data and hardware.
Just an idea so far, I never tried something like that.

You can call vTaskDelete for tasks created statically also.

Can you be sure that the task won’t hang the next time? Without knowing the exact cause of hang, it is just a shot in the dark. Watchdog is a usual way to catch hung application and reset the MCU.

You can delete static tasks too, and recreate them.

This is NOT a solution to your problem though, as restarting a task won’t deal with returning any global state (like mutexs) to a default state.

If you can’t use a timeout to have your task reset itself, where you have the option to know what you were doing and reset some of the state, a blind restart isn’t going to help eather, and will likely leave something in a bad state.

Thanks for your input.
I think you are right, that wasn’t the most clever idea :wink:
I will look for a way to detect a hanging situation in the task itself.