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] [December 2012 Threads] vTaskDelay(0) vs vTaskDelay(1)Posted by Mark Samarin on December 24, 2012 I just want to clairify that I understand what vTaskDelay(0) does vs vTaskDelay(1).
Calling vTaskDelay(0) will basically rerun the scheduler, without suspending the current task.
If a task changes a higher-priority task to the running state, the higher-priority task will not start until the next tick because thats when the scheduler will run again... unless vTaskDelay() is called.
So if the current task changes a higher-priority task to the running state, then calls vTaskDelay(0), the higher-priority task will take over during the current tick. But if the current task does not make any state changes to other tasks and calls vTaskDelay(0) then it will basically hiccup (scheduler runs) and keep going.
Is this correct?
So, unless a higher priority task has been made resheduled to run this cycle, the current task will resume.
Will any higher priority tasks that called vTaskDelay(1) earlier this cycle run again? I think they would have not becase the
, or are they resheduled to the next cycle?
effectivey yield to any higher priority tasks that are
RE: vTaskDelay(0) vs vTaskDelay(1)Posted by Mark Samarin on December 24, 2012 Whoops, everything after "Is this Correct?" is garbage. Please ignore.
RE: vTaskDelay(0) vs vTaskDelay(1)Posted by Richard Damon on December 24, 2012 Calling vTaskDelay(0) is effectively the same as calling vTaskYield(), it puts the task as ready at the bottom of its current priority and then runs the highest priority ready task. Note, that this will share time with tasks of the same priority level, but not run any tasks at a lower level, as the task is still ready. There is really no reason to explicitly call vTaskDelay(0), if you know the time delay is 0, it is better to call vTaskYield(), as it has less overhead, the option is more so that you can compute the delay you want, and get a result of 0 if you don't want any delay.
Calling vTaskDelay(1), makes the task not ready until the next tick, so when it switches to the highest priority ready task, that might be a task of lower priory.
As to changing a higher priority task to the running state, if you make a call that makes this happen, I believe that FreeRTOS will automatically run the scheduler and start the task, as that is normally what you want. If an interrupt causes the higher priority task to become ready, then when it is activated is a function of how you write the ISR. If the ISR invokes a task switch. The tick interrupt (which can cause tasks to become ready) will cause a task switch if preemption is enabled, if preemption is disabled then the reschedule will only occur on the current task blocking or yielding.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|