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


vTaskDelayUntil and vTaskSuspend

Posted by acehigh1971 on September 27, 2006
I would like to control a periodic task by suspending and resuming it with vTaskSuspend.

Suppose I have a task that is running:


and in another task I suspend this one by calling


The problem which I encounter is that when I call:


the task "aTask" runs for the amount of times needed to reach the current tick time continuosly and then runs again periodically as vTaskDelayUntil tells. Obviously other tasks interrupt it.
This is not good as when I resume this task I want that this task runs periodically again, immediatly.
It seems that the variable LastWake is not updated well if I do a suspend/resume.
Please note that if I do a suspend which lasts some minutes, the task runs for a lot of times continuously, not respecting the 10ms delay time.

Is there something I can do?
Am I wrong in using suspend and resume?
Am I wrong in using vTaskDelayUntil (obviously I don't want to use vTaskDelay as I want to perform the operations every 10 ms)?
Should I use instead a semaphore?

Any suggestion is appreciated, thanks.

RE: vTaskDelayUntil and vTaskSuspend

Posted by Nobody/Anonymous on September 27, 2006
When you block a task using TaskDelayUntil it is moved onto the delayed list. If you then suspend it it will be moved from the delayed list to the suspended list. Finally calling TaskResume() will then move it from the suspended list to the ready list. The important thing here is that it will be moved to the ready list even if the block time has not expired - it does not remember that it came from the delayed task list. Its state was changed from delayed to suspended to ready.

The previous wake time will be updated prior to the task being moved from the delayed list to the suspended list, so this variable should remain correct.

If the task is moved from the suspended list to the ready list it could run before the wanted next execution time. You could prevent this by checking the tick count value after the call to vTaskDelayUntil() then adjust the wait time and call delay again.

[ 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