b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

freertos操作系统_仓储系统_学ucos还是free rtos(4)

电脑杂谈  发布时间:2017-02-05 14:18:38  来源:网络整理

priority get an equal share of the processor time. */

listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );

在当型循环(while loop)开始之前,uxTopReadyPriority就被确保大于或等于优先级最高的就绪任务。while()循环从优先级uxTopReadyPriority开始,循环走下去从pxReadyTasksLists[]数组里找到就绪任务优先级最高的那个。接着listGET_OWNER_OF_NEXT_ENTRY()就抢占那个就绪列表中优先级最高的下一个就绪任务。

现在pxCurrentTCB指向了优先级最高的任务,并且当vTaskSwitchContext()返回硬件相关代码时开始运行那个任务。

那九行代码是FreeRTOS的绝对核心。其余FreeRTOS的8900行代码都是用来确保那九行代码,全都是用来保持优先级最高任务的运行的。

图3.2是一个大致的就绪列表看起来像什么的图。这个例子有三个优先级,有一个优先级为0的任务,没有优先级为1的任务,和三个优先级为2的任务。这张图是准确的,但不完整的;它的少掉一些细节,我们稍后将补充。

图3.2:FreeRTOS的就绪列表的基本视图

图3.2:FreeRTOS的就绪列表的基本视图

现在我们有了大致概述的方式,让我们去深究它的细节。我们将着于三个主要FreeRTOS的数据结构:任务,列表和队列。

3.4. 任务

所有操作系统的主要工作是运行和协调用户任务。像多数操作系统一样,FreeRTOS中的基本工作单元是任务。FreeRTOS的使用任务控制块(TCB)来表示每个任务。

任务控制块(TCB)

TCB的在tasks.c定义是这样的:

typedef struct tskTaskControlBlock

{

volatile portSTACK_TYPE *pxTopOfStack; /* Points to the location of

the last item placed on

the tasks stack. THIS

MUST BE THE FIRST MEMBER

OF THE STRUCT. */

xListItem xGenericListItem; /* List item used to place

the TCB in ready and

blocked queues. */

xListItem xEventListItem; /* List item used to place

the TCB in event lists.*/

unsigned portBASE_TYPE uxPriority; /* The priority of the task

where 0 is the lowest

priority. */

portSTACK_TYPE *pxStack; /* Points to the start of

the stack. */

signed char pcTaskName[ configMAX_TASK_NAME_LEN ]; /* Descriptive name given

to the task when created.

Facilitates debugging

only. */

#if ( portSTACK_GROWTH > 0 )


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-30698-4.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    每日福利
    热点图片
    拼命载入中...