Quality RTOS & Embedded Software

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


Loading

vTaskDelayUntil() vs software timer

Posted by aprados on January 15, 2019

Hello all,

i´m quite new to the FreeRTOS world. I´m in the reading and learning phase now.

I was wondering, what are the advantages of using a software timer (for a function called periodically) instead of calling vTaskDelayUntil() in a function called by the scheduler?

Calling vTaskDelayUntil() would put the task on "blocked" state. In which state would be a software timer callback that is waiting to be triggered?

Thank you!


vTaskDelayUntil() vs software timer

Posted by richarddamon on January 15, 2019

vTaskDelayUntil will create a new task to do the operation, while using a timer will have the code work as a call back of the Timer/Service Task.

Putting the code in a timer will have the advantage of possibly saving memory, as you don't need to create a new task, with its stack, as you are using the stack of the Timer/Service task.

There are several disadvantages though: A timer callback, since it uses the Timer/Service task will have the Priority of the Timer Service task, which means you can't make it run at a higher or lower task priority.

A timer callback is not supposed to block (to avoid affecting other timer callbacks), so if the routine needs to do operations that will block you should use a task instead.

If the operation will take significant time, it should not be a timer callback as that will affect other timer callbacks.

Generally I use timer callbacks for very short, light weight operations, and use a task for heavier weight operations. I typically have the Timer task set as one of the, if not the, highest priority tasks, so timer callback should be operations that would qualify for that sort of priority and don't need to block, which also implies the quick opeation.


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


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

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

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

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


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Mediatek

Renesas

RISC-V

SiFIve RISC-V

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