Quality RTOS & Embedded Software

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




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) 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.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists