In this tutorial we will be looking all the possible freeRtos configuration.

Task States

In the FreeRTOS a task can be in either of four different states viz., Running, Ready, Blocked and Suspended as shown in below image. FreeRtos States.png

1.Running: The task which is executing currently is said to be in running state. It owns the CPU.

2.Ready: The task which is neither suspended nor blocked but still not executing will be in ready state. It's not in running state because either a high priority or equal priority task is executing.

3.Blocked: A task will go in blocked state whenever it is waiting for an event to happen. The event can be completing a delay period or availability of a resource. The blocked tasks are not available for scheduling.

4.Suspended: When vTaskSuspend() is called, the task goes in suspended state. It can be resumed by calling xTaskResume(). The suspended tasks are also not available for scheduling.


API Details

Here we will discuss some of the mostly frequently used APIs related to task.

xTaskCreate()
Defination portBASE_TYPE xTaskCreate (
pdTASK_CODE pvTaskCode,
const portCHAR * const pcName,
unsigned portSHORT usStackDepth,
void *pvParameters,
unsigned portBASE_TYPE uxPriority,
xTaskHandle *pvCreatedTask);
Input Arguments
  1. pdTASK_CODE : Pointer to the task entry function
  1. const portCHAR * : A descriptive name for the task. It is a character pointer and is mainly used for debugging.
  1. unsigned portSHORT : The stack size of the task in terms of number of variables not the number of bytes
  1. void* : void pointer which will be used as the parameter for the task
  1. unsigned portBASE_TYPE : The task priority
  1. xTaskHandle* : Used to pass back a handle using which the task can be referenced
Return Value Returns TRUE on successful creation of task and adding it to ready list FALSE otherwise.
Description It creates a task and adds it to ready list.
Usage xTaskHandle TaskHandle_1;

static void MyTask1(void* pvParameters);

xTaskCreate( MyTask1, ( signed char * )"Task1", configMINIMAL_STACK_SIZE, NULL, 1, &TaskHandle_1 );