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


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 ]    [ 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