Embedded Programming: Freertos
Embedded Programming: Freertos
FreeRTOS
Function structure:
portTASK_FUNCTION( vATaskFunction, pvParameters )
{
While(1) //”for( ;; )” is an alternative for the super loop
{
x
}
}
Task States
Running
Ready
Blocked
Suspended
Task Scheduling
Pre-emptive Scheduling
Cooperative Scheduling
Task Scheduling
Pre-emptive Scheduling
◦ Runs task with highest priority
Task Scheduling
Cooperative Scheduling
◦ Task runs until it gives up its CPU time
◦ The task can not be pre-empted by another task
Task Priority
Each task is assigned a priority from 0 to
( configMAX_PRIORITIES - 1 ):
◦ configMAX_PRIORITIES is defined within FreeRTOSConfig.h.
Low priority numbers denote low priority tasks
Mutex API:
xSemaphoreCreateMutex()
xSemaphoreTake()
xSemaphoreGive()
FreeRTOS API: MessageQueues
Used to send messages between tasks/ between
interrupts and tasks