Difference between revisions of "Read Task Info : vTaskList()"
m (Explorer moved page Semaphores to Read Task Info : vTaskList()) |
|||
(23 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[category: Free RTOS with Arduino]] | [[category: Free RTOS with Arduino]] | ||
− | In | + | In earlier tutorials, we saw how to create, delete, suspend and resume the tasks.<br> |
− | + | In this tutorial, we will see how to read the Task info(state, Stack size, priority.<br> | |
− | + | ||
− | + | [[File:0ReadTaskInfo.png]] | |
− | + | ||
− | + | =API Details= | |
− | + | Here we will discuss some of the most frequently used APIs related to tasks. | |
− | + | <b>xTaskCreate()</b>: 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 [http://www.freertos.org/a00125.html this link] for more details.<br> | |
− | + | ||
− | + | <b>vTaskDelay()</b>: 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 [http://www.freertos.org/a00127.html this link] for more details.<br> | |
− | + | ||
− | + | <b>vTaskSuspend():</b> This function is used to Suspend a task, the suspended remains in the same state util it is resumed.<br> | |
− | it will | + | For this, we need to pass the handle of the tasks that needs to be suspended. Passing NULL will suspend own task. Check [http://www.freertos.org/a00130.html this link] for more details. |
+ | |||
+ | <b>vTaskResume():</b> This function is used to resume a suspended task. If the Resumed task has higher priority than the running task then it will preempt the running task or else stays in ready state<br> | ||
+ | For this, we need to pass the handle of the task to be resumed. Check [http://www.freertos.org/a00131.html this link] for more details. | ||
+ | |||
+ | <b>vTaskList():</b> This function is used to read the task details(name, state, priority, num). We need to pass a string pointer(buffer) to which it copies the above task details. The buffer size should be minimum 40 bytes per task. Check [http://www.freertos.org/a00021.html#vTaskList this link] for more details. | ||
<br><br> | <br><br> | ||
− | = | + | =Example1= |
− | + | In this example, we will be creating 3-tasks which run for some time and enter the blocked state allowing other tasks to run. We will include INT0 falling edge interrupt to read and display the current task list with all the task info. Every time interrupt is generated it will take the snapshot of tasks(name, state, priority, num) and sends on Serial port. | |
− | + | <html><script src="https://gist.github.com/SaheblalBagwan/c696f165daba3e2826cd3b9ebf33785f.js"></script></html> | |
− | + | ||
− | + | =Output1= | |
+ | [[FILE:VTaskList().png]] | ||
+ | <br> | ||
+ | All the tasks will be running for some time and enter the blocked state allowing other tasks to run. Task3 suspends and resumes the Task1 alternatively. | ||
+ | Whenever INT0 interrupt is generated, ISR will take the snapshot of all the task and sends it on the serial port. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | =Downloads= | |
+ | Download the complete project and libraries from [https://github.com/ExploreEmbedded/Arduino_FreeRTOS/archive/master.zip here].<br><br> | ||
− | + | Have an opinion, suggestion , question or feedback about the article let it out here! | |
+ | {{DISQUS}} |
Latest revision as of 17:54, 14 July 2016
In earlier tutorials, we saw how to create, delete, suspend and resume the tasks.
In this tutorial, we will see how to read the Task info(state, Stack size, priority.
Contents
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.
vTaskSuspend(): This function is used to Suspend a task, the suspended remains in the same state util it is resumed.
For this, we need to pass the handle of the tasks that needs to be suspended. Passing NULL will suspend own task. Check this link for more details.
vTaskResume(): This function is used to resume a suspended task. If the Resumed task has higher priority than the running task then it will preempt the running task or else stays in ready state
For this, we need to pass the handle of the task to be resumed. Check this link for more details.
vTaskList(): This function is used to read the task details(name, state, priority, num). We need to pass a string pointer(buffer) to which it copies the above task details. The buffer size should be minimum 40 bytes per task. Check this link for more details.
Example1
In this example, we will be creating 3-tasks which run for some time and enter the blocked state allowing other tasks to run. We will include INT0 falling edge interrupt to read and display the current task list with all the task info. Every time interrupt is generated it will take the snapshot of tasks(name, state, priority, num) and sends on Serial port.
Output1
All the tasks will be running for some time and enter the blocked state allowing other tasks to run. Task3 suspends and resumes the Task1 alternatively.
Whenever INT0 interrupt is generated, ISR will take the snapshot of all the task and sends it on the serial port.
Downloads
Download the complete project and libraries from here.
Have an opinion, suggestion , question or feedback about the article let it out here!