FreeRTOS 7.0.0 : Suspending the timer task

destremps wrote on Thursday, June 30, 2011:

I’m using ver 7.0.0. And really like the new timer addition. Is there a way to directly suspend the timer task? Presently I test a ‘flag’ in the top of each timer callback function. And if the flag is set will call vTaskSuspend(NULL). Thereby suspending the timer task. I wonder if there is an alternative way?

If you’re interested why I would want to do this read below (and feel free to comment on of course) :

In my project I sense an impending power fail with an interrupt. And signal the highest priority task in the system of such. The high priority task suspends all tasks except for one in particular. I do this by recording all task handles as they are created. And then calling vTaskSuspend and one by one suspending all the tasks except the high priority powerfail task and the one. The one task I want to keep alive happens to manage a flash file system which can gracefully exit what it is doing once it knows of the impending powerfail. There is enough time to do this - like 30ms. However the application most surely has some timers active. And their callback code is getting called. And I want it all to stop.

Any coments welcome.

rtel wrote on Thursday, June 30, 2011:

I have already opened a feature request to add a method of getting the handle to the idle task - so I don’t forget to add the functionality into the next version.  I can extend that to also include a method of obtaining the handle to the timer task.  That does not help you in the immediate term though.

If you want to edit the code yourself, then you can find only line in the FreeRTOS/Source/Timers.c file that calls xTaskCreate(), and replace the last parameter which is currently NULL with the address of a task handle variable in the normal way.  You can then make that a global variable (easy, but a bit dirty), or add in a function that returns the handle.


destremps wrote on Thursday, June 30, 2011:

Okay. To be able to get at those handles would be useful in the future. Particularly the timer task handle. For now what I have is functional. As long as I (and others are!)  disciplined enough to remember to include my ‘suspend’ code in the top of each timer callback function. I may go the edit route but will think about it for a bit. Thanks for your help!