champ1
Posts: 80
Joined: Tue Jul 17, 2018 12:36 am

How FreeRTOS chooses which task should execute at any given time.

Sat Sep 18, 2021 10:55 am

Hello everyone

Can anyone tell me how the following behavior of the system can be obtained in free rtos

T1 runs once for 8ms in every 38ms with Priority 2
T2 runs twice for 5ms in every 38ms with Priority1
T3 runs twice times for 10ms in every 38ms with Priority3

I use xTaskCreate function to create Task's and vTaskStartScheduler(); to start scheduler.

User avatar
B.Goode
Posts: 12980
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: How FreeRTOS chooses which task should execute at any given time.

Sat Sep 18, 2021 10:58 am

champ1 wrote:
Sat Sep 18, 2021 10:55 am
Hello everyone

Can anyone tell me how the following behavior of the system can be obtained in free rtos

T1 runs once for 8ms in every 38ms with Priority 2
T2 runs twice for 5ms in every 38ms with Priority1
T3 runs twice times for 10ms in every 38ms with Priority3

I use xTaskCreate function to create Task's and vTaskStartScheduler(); to start scheduler.

The organisation who develop, distribute and support that Operating System might know?
https://www.freertos.org/contact.html

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 29616
Joined: Sat Jul 30, 2011 7:41 pm

Re: How FreeRTOS chooses which task should execute at any given time.

Sat Sep 18, 2021 11:31 am

Are you using this on a Pi? On a Pico? On something else?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Applications Team.

ghellquist
Posts: 77
Joined: Thu Aug 02, 2012 8:47 am
Location: Stockholm Sweden

Re: How FreeRTOS chooses which task should execute at any given time.

Sun Sep 19, 2021 8:03 am

My suggestions. Not really specific to this OS. All require that the OS has a hardware tick function.

.1) Use the OS supplied period timers to start the task (xTimerCreate with uxAutoReload) . You might write the callback function to realease all the tasks to run.

.2) Each task uses the delay function ( vTaskDelay ) until next start time. The task needs to calculate the difference between "now" and when it wants to start.

.3) Variation: use the delay until function (vTaskDelayUntil ). Add cycle time to last startup time.

.4) Do the cycle calculations and starts outside the three tasks. Could as exemple be done as an extension to the tick interrupt. The tasks waits for next start, the tick function signals the task somehow to start.

Return to “General discussion”