FreeRTOS Task status information query

Source: Internet
Author: User

Uxtaskpriorityget (): Query the priority of a task
Vtaskpriorityset (): Change the task priority of a task
Uxtaskgetsystemstate (): Gets the status of the task in the system
Vtaskgetinfo (): Get a task information
Xtaskgetapplicationtasktag (): Gets the label value of a task
Xtaskgetcurrenttaskhandle (): Gets the task handle of the currently running task
Xtaskgethandle (): Find a handle to a task based on the name of the task
Xtaskgetidletaskhandle (): Gets the task handle of the idle task
Uxtaskgetstackhighwatermark (): Gets the history remaining minimum value of the task's stack, called "High watermark" in FreeRTOS
Etaskgetstate (): Gets the strong state of a task, the strong state is the Etaskstate type
Pctaskgetname (): Gets the task name of a task
Xtaskgettickcount (): Gets the system Time counter value
XTASKGETTICKCOUNTFROMISR (): Gets the time counter value in the Interrupt service function
Xtaskgetschedulerstate (): Gets the Task Scheduler's strong state, on or not turned on
Uxtaskgetnumberoftasks (): Gets the number of tasks present in the current system
Vtasklist (): Output details of all tasks in the current system in a tabular format
Vtaskgetruntimestats (): Gets the run time for each task
Vtasksetapplicationtasktag (): Set task label (tag) value
Setthreadlocalstoragepointer (): Set thread local storage pointer
Getthreadlocalstoragepointer (): Gets thread-local storage pointer

Examples of Use

/* * ubasetype_t uxtaskgetnumberoftasks (void) * ubasetype_t uxtaskgetsystemstate (taskstatus_t * Const PxTaskStatusArray , * const ubasetype_t uxarraysize, uint32_t * Const pultotalruntime) */taskstatus_t
*statusarray;

ubasetype_t Task_num;      Task_num=uxtaskgetnumberoftasks ();

Get the number of system tasks printf ("Uxtaskgetnumberoftasks%d\r\n", task_num); Statusarray=pvportmalloc (task_num*sizeof (taskstatus_t));//Application memory if (statusarray!=null)//Memory request succeeded {Arra     Ysize=uxtaskgetsystemstate ((taskstatus_t*) Statusarray,//Task Information Store array (ubasetype_t ) Task_num,//task information storage array size (uint32_t*) &totalruntime);//Save the system's total run time printf (
    "taskname\t\tpriority\t\ttasknumber\t\t\r\n"); for (x=0;x<task_num;x++) {printf ("%s\t\t%d\t\t\t%d\t\t\t\r\n", statusarray[ X].pctaskname,//Task Name (int) statusarray[x].uxcurrentpriority,Task priority (int) statusarray[x].xtasknumber); Task number}} vportfree (Statusarray); Freeing memory

Experimental Phenomena

Uxtaskgetnumberoftasks 5

taskname        priority        tasknumber      
query_task      3               5           
led0_task       2               4           
IDLE            0               2           
start_task      1               1           
Tmr SVC              3

Examples of Use

/* * taskhandle_t xtaskgethandle (const char *pcnametoquery) * void Vtaskgetinfo (taskhandle_t xtask, taskstatus_t *pxTas    
Kstatus, * basetype_t xgetfreestackspace, etaskstate eState) */taskhandle_t Taskhandle;

taskstatus_t TaskStatus;         Taskhandle=xtaskgethandle ("Led0_task"); Get task handle//Get Led0_task task information based on Task name Vtaskgetinfo ((taskhandle_t) Taskhandle,//task handle (taskstatus_t*) &amp ;    TaskStatus,//Task Information structure (basetype_t) pdtrue,//Allow statistic task stack history minimum remaining size (etaskstate         ) einvalid);
function to get the task run strong printf ("Task Name:%s\r\n", taskstatus.pctaskname);
printf ("Task number:%d\r\n", (int) taskstatus.xtasknumber);
printf ("Mission Strong:%d\r\n", taskstatus.ecurrentstate);
printf ("Task Current priority:%d\r\n", (int) taskstatus.uxcurrentpriority);
printf ("Task Base priority:%d\r\n", (int) taskstatus.uxbasepriority);
printf ("Task stack base address:% #x \ r \ n", (int) taskstatus.pxstackbase); printf ("Task stack history remaining minimum:%d\r\n ", Taskstatus.usstackhighwatermark); 

Experimental Phenomena

Task Name:                led0_task
Task number:              4
Task strong state:              2
Task Current priority:         2
Task Base priority:           2
task stack base address:         0x200012e8
Task Stack history remaining minimum value:  108

Examples of Use

/* * Etaskstate etaskgetstate (taskhandle_t xtask) */typedef enum {erunning = 0,/* A task is querying the state of itself, so must is running. */Eready,/* The task being queried is in a read or pending Ready list. */eblocked,/* The task being queried is in the Blocked state. */esuspended,/* The task being queried is in the Suspended state, or was in the Blocked state with an infinite ti Me out. */edeleted,/* The task being queried have been deleted, but its TCB have not yet been freed. */einvalid/* Used as an ' invalid state ' value.

*/} Etaskstate;        Taskhandle=xtaskgethandle ("Query_task");            Gets the task handle taskstate=etaskgetstate (Taskhandle) According to the task name;
        Gets the task of the Query_task task Strong switch ((int) taskstate) {case erunning:sprintf (taskinfo, "Running");
    Break
        Case eready:sprintf (TaskInfo, "ready");
    Break
        Case esuspended:sprintf (TaskInfo, "Suspended");
    BreakCase edeleted:sprintf (TaskInfo, "Deleted");
    Break
        Case einvalid:sprintf (TaskInfo, "Invalid");
Break } printf ("Task Strong value:%d, corresponding to the strong state:%s\r\n", taskstate,taskinfo);

Experimental Phenomena

Task strong state value: 0, the corresponding strong state is: Running

Examples of Use

/
* void Vtasklist (char * pcwritebuffer) */

vtasklist (infobuffer);          Get information on all Tasks
printf ("%s\r\n", InfoBuffer);

Experimental Phenomena

Query_task      R   3   192 5
IDLE            r   0   108 2
led0_task       B   2   108 4
TMR SVC         S  236 3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.