FreeRTOS Tetris
|
Group that contains task utility macros & functions. More...
Macros | |
#define | tskIDLE_PRIORITY ( ( UBaseType_t ) 0U ) |
Defines the priority used by the idle task. This must not be modified. | |
Functions | |
eTaskState | eTaskGetState (TaskHandle_t xTask) PRIVILEGED_FUNCTION |
Obtain the state of any task. States are encoded by the eTaskState enumerated type. More... | |
void | vTaskGetInfo (TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState) PRIVILEGED_FUNCTION |
Populates a TaskStatus_t structure with information about a task. More... | |
void | vTaskPrioritySet (TaskHandle_t xTask, UBaseType_t uxNewPriority) PRIVILEGED_FUNCTION |
Set the priority of any task. More... | |
TickType_t | xTaskGetTickCount (void) PRIVILEGED_FUNCTION |
TickType_t | xTaskGetTickCountFromISR (void) PRIVILEGED_FUNCTION |
This is a version of xTaskGetTickCount() that is safe to be called from an ISR - provided that TickType_t is the natural word size of the microcontroller being used or interrupt nesting is either not supported or not being used. More... | |
UBaseType_t | uxTaskGetNumberOfTasks (void) PRIVILEGED_FUNCTION |
char * | pcTaskGetName (TaskHandle_t xTaskToQuery) PRIVILEGED_FUNCTION |
TaskHandle_t | xTaskGetHandle (const char *pcNameToQuery) PRIVILEGED_FUNCTION |
UBaseType_t | uxTaskGetStackHighWaterMark (TaskHandle_t xTask) PRIVILEGED_FUNCTION |
Returns the high water mark of the stack associated with xTask . That is, the minimum free stack space there has been (in words, so on a 32 bit machine a value of 1 means 4 bytes) since the task started. The smaller the returned number the closer the task has come to overflowing its stack. More... | |
BaseType_t | xTaskCallApplicationTaskHook (TaskHandle_t xTask, void *pvParameter) PRIVILEGED_FUNCTION |
Calls the hook function associated with xTask. Passing xTask as NULL has the effect of calling the Running tasks (the calling task) hook function. More... | |
TaskHandle_t | xTaskGetIdleTaskHandle (void) PRIVILEGED_FUNCTION |
UBaseType_t | uxTaskGetSystemState (TaskStatus_t *const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t *const pulTotalRunTime) PRIVILEGED_FUNCTION |
uxTaskGetSystemState() populates an TaskStatus_t structure for each task in the system. TaskStatus_t structures contain, among other things, members for the task handle, task name, task priority, task state, and total amount of run time consumed by the task. See the TaskStatus_t structure definition in this file for the full member list. More... | |
void | vTaskList (char *pcWriteBuffer) PRIVILEGED_FUNCTION |
Lists all the current tasks, along with their current state and stack usage high water mark. More... | |
void | vTaskGetRunTimeStats (char *pcWriteBuffer) PRIVILEGED_FUNCTION |
Call uxTaskGetSystemState(), then format part of the uxTaskGetSystemState() output into a human readable table that displays the amount of time each task has spent in the Running state in both absolute and percentage terms. More... | |
Group that contains task utility macros & functions.
eTaskState eTaskGetState | ( | TaskHandle_t | xTask | ) |
#include <task.h>
Obtain the state of any task. States are encoded by the eTaskState enumerated type.
xTask | Handle of the task to be queried. |
char* pcTaskGetName | ( | TaskHandle_t | xTaskToQuery | ) |
#include <task.h>
xTaskToQuery
. A task can query its own name by either passing in its own handle, or by setting xTaskToQuery to NULL. UBaseType_t uxTaskGetNumberOfTasks | ( | void | ) |
#include <task.h>
UBaseType_t uxTaskGetStackHighWaterMark | ( | TaskHandle_t | xTask | ) |
#include <task.h>
Returns the high water mark of the stack associated with xTask
. That is, the minimum free stack space there has been (in words, so on a 32 bit machine a value of 1 means 4 bytes) since the task started. The smaller the returned number the closer the task has come to overflowing its stack.
xTask | Handle of the task associated with the stack to be checked. Set xTask to NULL to check the stack of the calling task. |
xTask
was created. UBaseType_t uxTaskGetSystemState | ( | TaskStatus_t *const | pxTaskStatusArray, |
const UBaseType_t | uxArraySize, | ||
uint32_t *const | pulTotalRunTime | ||
) |
#include <task.h>
uxTaskGetSystemState() populates an TaskStatus_t structure for each task in the system. TaskStatus_t structures contain, among other things, members for the task handle, task name, task priority, task state, and total amount of run time consumed by the task. See the TaskStatus_t structure definition in this file for the full member list.
pxTaskStatusArray | A pointer to an array of TaskStatus_t structures. The array must contain at least one TaskStatus_t structure for each task that is under the control of the RTOS. The number of tasks under the control of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function. |
uxArraySize | The size of the array pointed to by the pxTaskStatusArray parameter. The size is specified as the number of indexes in the array, or the number of TaskStatus_t structures contained in the array, not by the number of bytes in the array. |
pulTotalRunTime | If configGENERATE_RUN_TIME_STATS is set to 1 in FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the total run time (as defined by the run time stats clock, see http://www.freertos.org/rtos-run-time-stats.html) since the target booted. pulTotalRunTime can be set to NULL to omit the total run time information. |
uxArraySize
parameter was too small.Example usage:
void vTaskGetInfo | ( | TaskHandle_t | xTask, |
TaskStatus_t * | pxTaskStatus, | ||
BaseType_t | xGetFreeStackSpace, | ||
eTaskState | eState | ||
) |
#include <task.h>
Populates a TaskStatus_t structure with information about a task.
xTask | Handle of the task being queried. If xTask is NULL then information will be returned about the calling task. |
pxTaskStatus | A pointer to the TaskStatus_t structure that will be filled with information about the task referenced by the handle passed using the xTask parameter. |
xGetFreeStackSpace | The TaskStatus_t structure contains a member to report the stack high water mark of the task being queried. Calculating the stack high water mark takes a relatively long time, and can make the system temporarily unresponsive - so the xGetFreeStackSpace parameter is provided to allow the high water mark checking to be skipped. The high watermark value will only be written to the TaskStatus_t structure if xGetFreeStackSpace is not set to pdFALSE; |
eState | The TaskStatus_t structure contains a member to report the state of the task being queried. Obtaining the task state is not as fast as a simple assignment - so the eState parameter is provided to allow the state information to be omitted from the TaskStatus_t structure. To obtain state information then set eState to eInvalid - otherwise the value passed in eState will be reported as the task state in the TaskStatus_t structure. |
Example usage:
void vTaskGetRunTimeStats | ( | char * | pcWriteBuffer | ) |
#include <task.h>
Call uxTaskGetSystemState(), then format part of the uxTaskGetSystemState() output into a human readable table that displays the amount of time each task has spent in the Running state in both absolute and percentage terms.
Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total accumulated execution time being stored for each task. The resolution of the accumulated time value depends on the frequency of the timer configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. Calling vTaskGetRunTimeStats() writes the total execution time of each task into a buffer, both as an absolute count value and as a percentage of the total system execution time.
vTaskGetRunTimeStats() has a dependency on the sprintf() C library function that might bloat the code size, use a lot of stack, and provide different results on different platforms. An alternative, tiny, third party, and limited functionality implementation of sprintf() is provided in many of the FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note printf-stdarg.c does not provide a full snprintf() implementation!).
It is recommended that production systems call uxTaskGetSystemState() directly to get access to raw stats data, rather than indirectly through a call to vTaskGetRunTimeStats().
pcWriteBuffer | A buffer into which the execution times will be written, in ASCII form. This buffer is assumed to be large enough to contain the generated report. Approximately 40 bytes per task should be sufficient. |
void vTaskList | ( | char * | pcWriteBuffer | ) |
#include <task.h>
Lists all the current tasks, along with their current state and stack usage high water mark.
Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or suspended ('S').
vTaskList() calls uxTaskGetSystemState(), then formats part of the uxTaskGetSystemState() output into a human readable table that displays task names, states and stack usage.
vTaskList() has a dependency on the sprintf() C library function that might bloat the code size, use a lot of stack, and provide different results on different platforms. An alternative, tiny, third party, and limited functionality implementation of sprintf() is provided in many of the FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note printf-stdarg.c does not provide a full snprintf() implementation!).
It is recommended that production systems call uxTaskGetSystemState() directly to get access to raw stats data, rather than indirectly through a call to vTaskList().
pcWriteBuffer | A buffer into which the above mentioned details will be written, in ASCII form. This buffer is assumed to be large enough to contain the generated report. Approximately 40 bytes per task should be sufficient. |
void vTaskPrioritySet | ( | TaskHandle_t | xTask, |
UBaseType_t | uxNewPriority | ||
) |
#include <task.h>
Set the priority of any task.
A context switch will occur before the function returns if the priority being set is higher than the currently executing task.
xTask | Handle to the task for which the priority is being set. Passing a NULL handle results in the priority of the calling task being set. |
uxNewPriority | The priority to which the task will be set. |
Example usage:
BaseType_t xTaskCallApplicationTaskHook | ( | TaskHandle_t | xTask, |
void * | pvParameter | ||
) |
#include <task.h>
Calls the hook function associated with xTask. Passing xTask as NULL has the effect of calling the Running tasks (the calling task) hook function.
pvParameter
is passed to the hook function for the task to interpret as it wants. The return value is the value returned by the task hook function registered by the user.
TaskHandle_t xTaskGetHandle | ( | const char * | pcNameToQuery | ) |
#include <task.h>
pcNameToQuery
. NULL is returned if no matching name is found. TaskHandle_t xTaskGetIdleTaskHandle | ( | void | ) |
#include <task.h>
TickType_t xTaskGetTickCount | ( | void | ) |
#include <task.h>
TickType_t xTaskGetTickCountFromISR | ( | void | ) |
#include <task.h>
This is a version of xTaskGetTickCount() that is safe to be called from an ISR - provided that TickType_t is the natural word size of the microcontroller being used or interrupt nesting is either not supported or not being used.