FreeRTOS Round Robin

cdb1702 wrote on Monday, December 07, 2015:

What are ,in the source code of FreeRTOS.the functions that make the round robin in the case of tasks with the same priority?
The following example is taken from USING THE FREERTOS REAL TIME KERNEL A Practical Guide
Richard Barry
void vTaskFunction( void *pvParameters )
char pcTaskName;
volatile unsigned long ul;
The string to print out is passed in via the parameter. Cast this to a
character pointer. /
pcTaskName = ( char * ) pvParameters;
As per most tasks, this task is implemented in an infinite loop. /
for( ;; )
Print out the name of this task. /
vPrintString( pcTaskName );
Delay for a period. /
for( ul = 0; ul < mainDELAY_LOOP_COUNT; ul++ )
This loop is just a very crude delay implementation. There is
nothing to do in here. Later exercises will replace this crude
loop with a proper delay/sleep function. /
Define the strings that will be passed in as the task parameters. These are
defined const and not on the stack to ensure they remain valid when the tasks are
executing. /
static const char pcTextForTask1 = “Task 1 is running\r\n”;
static const char pcTextForTask2 = “Task 2 is running\t\n”;
int main( void )
Create one of the two tasks. /
xTaskCreate( vTaskFunction, /
Pointer to the function that implements
the task. /
“Task 1”, /
Text name for the task. This is to
facilitate debugging only. /
1000, /
Stack depth - most small microcontrollers
will use much less stack than this. /
)pcTextForTask1, /
Pass the text to be printed into the task
using the task parameter. /
1, /
This task will run at priority 1. /
NULL ); /
We are not using the task handle. /
Create the other task in exactly the same way. Note this time that multiple
tasks are being created from the SAME task implementation (vTaskFunction). Only
the value passed in the parameter is different. Two instances of the same
task are being created. /
xTaskCreate( vTaskFunction, “Task 2”, 1000, (void
)pcTextForTask2, 1, NULL );
Start the scheduler so our tasks start executing. /
If all is well then main() will never reach here as the scheduler will
now be running the tasks. If main() does reach here then it is likely that
there was insufficient heap memory available for the idle task to be created.
CHAPTER 5 provides more information on memory management. */
for( ;; );

rtel wrote on Monday, December 07, 2015:

Search for

#if ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) )

in this file

to see the souce lines.

cdb1702 wrote on Wednesday, December 09, 2015:

Thank you
Carlo De Bonis

cdb1702 wrote on Wednesday, December 09, 2015:

I am using FreeRTOS V7.1.1 - Copyright © 2012 Real Time Engineers Ltd. and in this version there is not the funnction
BaseType_t xTaskIncrementTick( void )
nor is this the definition of configUSE_TIME_SLICING
but the example taken from USING THE FREERTOS REAL TIME KERNEL A Practical Guide it is earlier