Quality RTOS & Embedded Software

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


Tick rounding

Posted by znatok on April 30, 2014

Hi, If I need guaranteed at least 2 ticks delay should I use vTaskDelay( 2 ) or vTaskDelay( 3 ) ?

Tick rounding

Posted by davedoors on April 30, 2014

vTaskDelay(3) means 3 tick interrupts from the time the function is called. The function will be called part way through a time slice so the first tick interrupt will come after a fraction of a time slice, the second one complete time slice later, and the third another complete time slice after that. So 3 is your answer because it means two complete time slices plus whatever fraction of a time slice is left between when the function is called and the next tick interrupt.

Tick rounding

Posted by znatok on April 30, 2014

Thanks. That's exactly what I was asking for.

Now another question.

My task blocks on rc = xQueueReceive( xQueue, data, xTicksToWait ); Queue is updated from UART IRQ for example.

If xTicksToWait expires but due to low priority task is not executed for some time. And during this time IRQ executed and Queue updated. What would xQueueReceive return in this case? In other words who has a higher precedence expiration, Queue update of first occurred between two?

Tick rounding

Posted by rtel on April 30, 2014


1) A task is blocked on a queue. 2) The task unblocked because there is a time out, but because of its priority it does not run. 3) An interrupt writes to the queue 4) The task does get some CPU time after the interrupt has written to the queue


The xQueueReceive() function will return pdPASS and the item that was written to the queue between the task unblocking and the task actually running.


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

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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

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

Xilinx Microblaze and Zynq partner