16-FreeRTOS任务应用函数(2)

简介: 16-FreeRTOS任务应用函数(2)
    uxTaskPriorityGet() 查询某个任务的优先级。vTaskPrioritySet() 改变某个任务的任务优先级。uxTaskGetSystemState() 获取系统中任务状态。vTaskGetInfo() 获取某个任务信息。xTaskGetApplicationTaskTag() 获取某个任务的标签(Tag)值。xTaskGetCurrentTaskHandle() 获取当前正在运行的任务的任务句柄。xTaskGetHandle() 根据任务名字查找某个任务的句柄xTaskGetIdleTaskHandle() 获取空闲任务的任务句柄。uxTaskGetStackHighWaterMark()获取任务的堆栈的历史剩余最小值,FreeRTOS 中叫做“高水位线”eTaskGetState() 获取某个任务的壮态,这个壮态是 eTaskState 类型。pcTaskGetName() 获取某个任务的任务名字。xTaskGetTickCount() 获取系统时间计数器值。xTaskGetTickCountFromISR() 在中断服务函数中获取时间计数器值xTaskGetSchedulerState() 获取任务调度器的壮态,开启或未开启。uxTaskGetNumberOfTasks() 获取当前系统中存在的任务数量。vTaskList()以一种表格的形式输出当前系统中所有任务的详细信息。vTaskGetRunTimeStats() 获取每个任务的运行时间。vTaskSetApplicationTaskTag() 设置任务标签(Tag)值。SetThreadLocalStoragePointer() 设置线程本地存储指针GetThreadLocalStoragePointer() 获取线程本地存储指针


    1-任务标签获取(xTaskGetApplicationTaskTag)


    1.1 函数说明

    TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTaskGetApplicationTaskTagFromISR);

    TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );

    configUSE_APPLICATION_TASK_TAG必须设置为1

    xTaskGetApplicationTaskTagFromISR是在中断服务中调用的另一个版本。


    1.2 参数描述

    xTask :正在查询任务的句柄。任务可以使用NULL作为参数值查询自己的标记值。


    1.3 用例

      /* In this example, an integer is set as the task tag value. */void vATask( void *pvParameters ){    /* Assign a tag value of 1 to the currently executing task.    The (void *) cast is used to prevent compiler warnings. */    vTaskSetApplicationTaskTag( NULL, ( void * ) 1 );
          for( ;; )    {        /* Rest of task code goes here. */    }}
      void vAFunction( void ){TaskHandle_t xHandle;int iReturnedTaskHandle;
         /* Create a task from the vATask() function, storing the handle to the   created task in the xTask variable. */
         /* Create the task. */   if( xTaskCreate(             vATask,         /* Pointer to the function that implements                                the task. */             "Demo task",    /* Text name given to the task. */             STACK_SIZE,     /* The size of the stack that should be created                                for the task.  This is defined in words, not                                bytes. */             NULL,           /* The task does not use the                              parameter. */             TASK_PRIORITY,  /* The priority to assign to the newly created                                task. */             &xHandle        /* The handle to the task being created will be                                placed in xHandle. */             ) == pdPASS )   {       /* The task was created successfully.  Delay for a short period to allow       the task to run. */       vTaskDelay( 100 );
             /* What tag value is assigned to the task?  The returned tag value is       stored in an integer, so cast to an integer to prevent compiler       warnings. */       iReturnedTaskHandle = ( int ) xTaskGetApplicationTaskTag( xHandle );   }}


      2- 当前任务句柄获取(xTaskGetCurrentTaskHandle)


      2.1 函数描述

      TaskHandle_t xTaskGetCurrentTaskHandle( void );

      INCLUDE_xTaskGetCurrentTaskHandle 必须设置为 1 才能使用此函数。


      2.2 函数描述

      Returns:

      当前正在运行(调用)任务的句柄。

      相关文章
      |
      4月前
      |
      API 调度
      【FreeRTOS】软件定时器的使用
      【FreeRTOS】软件定时器的使用
      113 0
      |
      11月前
      |
      API
      FreeRTOS学习笔记—FreeRTOS移植
      本文学习了如何移植FreeRTOS到自己的STM32工程。最后,根据正点原子提供的测试main函数,测试了移植效果。
      387 0
      FreeRTOS学习笔记—FreeRTOS移植
      |
      11月前
      |
      传感器 调度 开发者
      【Freertos基础入门】freertos任务的优先级
      【Freertos基础入门】freertos任务的优先级
      383 0
      |
      IDE 调度 开发工具
      如何在S32DS中使用SystemView分析FreeRTOS
      如何在S32DS中使用SystemView分析FreeRTOS
      如何在S32DS中使用SystemView分析FreeRTOS
      |
      4月前
      |
      消息中间件 Web App开发 API
      FreeRTOS介绍 和 将FreeRTOS移植到STM32F103C8T6
      FreeRTOS介绍 和 将FreeRTOS移植到STM32F103C8T6
      FreeRTOS介绍 和 将FreeRTOS移植到STM32F103C8T6
      |
      3月前
      |
      消息中间件 算法 编译器
      【FreeRTOS(一)】FreeRTOS新手入门——初识FreeRTOS
      【FreeRTOS(一)】FreeRTOS新手入门——初识FreeRTOS
      |
      11月前
      |
      调度 开发者
      【Freertos基础入门】2个Freertos的Delay函数
      【Freertos基础入门】2个Freertos的Delay函数
      624 1
      |
      消息中间件 算法 安全
      RTOS实时操作系统中RT-Thread、FreeRTOS和uCOS 选择哪一个学习比较好?
      RTOS实时操作系统中RT-Thread、FreeRTOS和uCOS 选择哪一个学习比较好?
      |
      存储 编解码 调度
      17-FreeRTOS任务应用函数(3)
      17-FreeRTOS任务应用函数(3)
      |
      测试技术 API 调度
      15-FreeRTOS任务应用函数(1)
      15-FreeRTOS任务应用函数(1)