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

Biasing task start times with vTaskDelayUntil

Posted by Richard on October 19, 2005
[moved from bug report to support forum]

Hello,

I'm trying to bias or stagger task start times using
xLastWakeTime as in the examples for vTaskDelayUntil().

For example,

task1() does something like:

xLastWakeTime = xTaskGetTickCount();

for (EVER)
{

// Wait for the next cycle.
vTaskDelayUntil( &xLastWakeTime, xFrequency );
...

which is fine - it's my understanding since the tasks
are created before the scheduler starts - that
xLastWakeTime will be 0.

task2() does this:

xLastWakeTime = (xTaskGetTickCount() +
((portTickType)15 / portTICK_RATE_MS ));

for (EVER)
{

vTaskDelayUntil( &xLastWakeTime, xFrequency );


....

In this case - I'd expect task2() to run 15 ms after
task1 -
but at the same rate since xFrequency is the same in
both examples. Also - portTICK_RATE_MS = 1 since the
system
is running with a 1KHz tick rate.

What I'm seeing is that task2() is running much more
frequently than task1 - in some instances almost 15 times
more frequently. I don't understand why this is happening.

Thanks In Advance for your help,

RE: Biasing task start times with vTaskDelayUntil

Posted by Richard on October 19, 2005
I think the scenario is likely to be as follows:

For task 1 the first start time is 0.
For task 2 the second start time is 15.

Now if the scheduler started instantaniously task 2 would start 15 ticks after task 1, provided task 1 had either completed and blocked, or task 2 had priority higher than task 1.

However, the scheduler does not start instantly, and other code will first execute. If more than 15 ticks has gone by the start time for task 2 will have expired before it makes its first call to vTaskDelayUnilt(). As the time it wants to start is in the past it will execute immediately. It may therefore execute immediately following task 1 - or even before task 1 depending on their relative priorities and creation order.

I cannot explain yet while one task would run more frequently than the others. Can you provide a more full example of code exhibiting this problem? Is there any conflict between the various xLastWakeTime variables being used?

I have sent you a suggestion for how the desired task staggering might be accomplished.

Regards.


[ 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