STM32 FreeRTOS: FreeRTOS Scheduler

Work in Process

Stay updated with the STM32 Microcontroller with FreeRTOS blogs
STM32 Microcontroller and FreeRTOS Development

The scheduling algorithm is the software routine that decides which ready state task to transition into the running state.

Round Robin: the scheduler will ensure tasks that share priority are selected to enter the running state in turn. The Round Robin scheduling algorithm in FreeRTOS does not guarantee time is shared equally between tasks of equal priority, only that ready state tasks of equal priority will enter the running state in turn.

Fixed priority: this scheduler does not change the priority assigned to the tasks being scheduled but also does not prevent the tasked from changing their own priority or that of other tasks.

Pre-emptive: this scheduler will immediately preempt the running state task if a task that has priority higher than the running state task enters the ready state. Being pre-empted means being involuntarily (without explicitly yielding or blocking) moved out of the running state and into the ready state to allow a different task to enter the running state.

Time slicing: this scheduler shares processing time between tasks of equal priority, even when the task does not explicitly yield or enter the blocked state. Scheduling algorithms described as using time slicing will select a new task to enter the running state at the end of each time slice if there are other ready state tasks that have the same priority as running task. A time slice is equal to the time between two RTOS tick interrupts.

// FreeRTOSConfig.h

// Preemptive priority scheduler
// No automatic round-robin for equal priorities
// Deterministic execution until voluntary block/yield
#define configUSE_PREEMPTION     1 
#define configUSE_TIME_SLICING   0

// Priority-based preemptive scheduling
// Round-robin between equal priorities
#define configUSE_PREEMPTION     1 
#define configUSE_TIME_SLICING   1 

// FreeRTOSConfig.h

#define configENABLE_FPU                         0
#define configENABLE_MPU                         0
#define configSUPPORT_STATIC_ALLOCATION          1
#define configSUPPORT_DYNAMIC_ALLOCATION         1
#define configUSE_PREEMPTION                     1
#define configUSE_TIME_SLICING                   1
#define configUSE_IDLE_HOOK                      0
#define configUSE_TICK_HOOK                      0
#define configUSE_QUEUE_SETS                     1
#define configUSE_TRACE_FACILITY                 1
#define configUSE_16_BIT_TICKS                   0
#define configUSE_MUTEXES                        1
#define configUSE_TASK_NOTIFICATIONS             1
#define configUSE_RECURSIVE_MUTEXES              1
#define configUSE_COUNTING_SEMAPHORES            1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION  0
#define configCPU_CLOCK_HZ                       ( SystemCoreClock ) // defined in system_stm32f4xx.c
#define configTICK_RATE_HZ                       ((TickType_t)1000)
#define configMAX_PRIORITIES                     ( 56 )
#define configMINIMAL_STACK_SIZE                 ((uint16_t)128)
#define configTOTAL_HEAP_SIZE                    ((size_t)15360)
#define configMAX_TASK_NAME_LEN                  ( 16 )
#define configQUEUE_REGISTRY_SIZE                8


Back to top of the page
This entry was posted in Embedded System. Bookmark the permalink.