Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

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.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS