In earlier tutorials, we saw how to create in the init and use it.
In this tutorial, we will see how to create a task from other tasks.


API Details

Here we will discuss some of the most frequently used APIs related to tasks.

xTaskCreate(): This interface is used to create a new Task, if the task is successfully created then it returns pdPass(1) or else errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY(-1). Check this link for more details.

vTaskDelay(): This function is used to delay/block the task for specified delay time(ticks). INCLUDE_vTaskDelay needs to be set to 1 in FreeRtosConfig.h file for using this function. Check this link for more details.

vTaskDelete():This function is used to delete as task. We need to pass the taskHandle of the task to be deleted.
To delete the own task we should pass NULL as parameter.
Please check this link for detials.

vTaskPrioritySet(): This function is used to change/Set the priority of a task.
For this we need to pass the handle of the task and new priority to vTaskPrioritySet() function.
Check this link for more details.

vTaskPriorityGet(): This function is used to get the priority of a task.
For this we need to pass the handle of the task and it will return the task.
Check this link for more details.

Example

Output

TaskPriorityChange.png
0. Serial port is initialized and 2-Tasks are created with different priorities. Setup message is printed.