vTaskDelayUntil and vTaskSuspend
Posted by acehigh1971
on September 27, 2006
I would like to control a periodic task by suspending and resuming it with vTaskSuspend.
Suppose I have a task that is running:
and in another task I suspend this one by calling
The problem which I encounter is that when I call:
the task "aTask" runs for the amount of times needed to reach the current tick time continuosly and then runs again periodically as vTaskDelayUntil tells. Obviously other tasks interrupt it.
This is not good as when I resume this task I want that this task runs periodically again, immediatly.
It seems that the variable LastWake is not updated well if I do a suspend/resume.
Please note that if I do a suspend which lasts some minutes, the task runs for a lot of times continuously, not respecting the 10ms delay time.
Is there something I can do?
Am I wrong in using suspend and resume?
Am I wrong in using vTaskDelayUntil (obviously I don't want to use vTaskDelay as I want to perform the operations every 10 ms)?
Should I use instead a semaphore?
Any suggestion is appreciated, thanks.
RE: vTaskDelayUntil and vTaskSuspend
Posted by Nobody/Anonymous
on September 27, 2006
When you block a task using TaskDelayUntil it is moved onto the delayed list. If you then suspend it it will be moved from the delayed list to the suspended list. Finally calling TaskResume() will then move it from the suspended list to the ready list. The important thing here is that it will be moved to the ready list even if the block time has not expired - it does not remember that it came from the delayed task list. Its state was changed from delayed to suspended to ready.
The previous wake time will be updated prior to the task being moved from the delayed list to the suspended list, so this variable should remain correct.
If the task is moved from the suspended list to the ready list it could run before the wanted next execution time. You could prevent this by checking the tick count value after the call to vTaskDelayUntil() then adjust the wait time and call delay again.
Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd..
See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.