FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [September 2006 Threads] vTaskDelayUntil and vTaskSuspendPosted 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:
aTask { for(;;) { .. .. .. vTaskDelayUntil(&LastWake,10/portTICK_RATE_MS); } }
and in another task I suspend this one by calling
vTaskSuspend(aTask_handle);
The problem which I encounter is that when I call:
vTaskResume(aTask_handle);
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 vTaskSuspendPosted 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) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|