freertos taskTCB xList xListItem xQUEUE 结构体 源码分析
2014-06-11 00:00
495 查看
摘要: freertos taskTCB xList xListItem xQUEUE 结构体源码 任务控制块、链表、队列结构
任务结构体 typedef struct tskTaskControlBlock { volatile portSTACK_TYPE *pxTopOfStack; //指向任务堆栈结束处 #if ( portUSING_MPU_WRAPPERS == 1 ) xMPU_SETTINGS xMPUSettings; /*接口 TCB STRUCT第二个成员 */ #endif xListItem xGenericListItem; //用于把TCB插入就绪链表或等待链表 xListItem xEventListItem; //用于把TCB插入事件链表(如消息队列) unsigned portBASE_TYPE uxPriority; /*任务优先级 0 is the lowest priority. */ portSTACK_TYPE *pxStack; /*< 指向栈的开始 */ signed char pcTaskName[ configMAX_TASK_NAME_LEN ];/*< 描述创建任务时的名称,便于调试 */ #if ( portSTACK_GROWTH > 0 ) portSTACK_TYPE *pxEndOfStack; /*< 指向栈底内存. */ #endif #if ( portCRITICAL_NESTING_IN_TCB == 1 ) //临界 unsigned portBASE_TYPE uxCriticalNesting; /*< 占着关键的部分nesting depth for ports that do not maintain their own count in the port layer. */ #endif #if ( configUSE_TRACE_FACILITY == 1 ) //追踪功能 unsigned portBASE_TYPE uxTCBNumber; /*< TCB 创建时计数. 调试时记录任务删除和重新创建 */ unsigned portBASE_TYPE uxTaskNumber; /*< 存储一个值供第三方追踪. */ #endif #if ( configUSE_MUTEXES == 1 ) //互斥器 unsigned portBASE_TYPE uxBasePriority; /*< 最后分配给任务的优先级 优先级继承机制 */ #endif #if ( configUSE_APPLICATION_TASK_TAG == 1 ) pdTASK_HOOK_CODE pxTaskTag; //任务标签,用于识别 #endif #if ( configGENERATE_RUN_TIME_STATS == 1 ) //运行时间状态 unsigned long ulRunTimeCounter; /*< 运行状态时的时间 */ #endif #if ( configUSE_NEWLIB_REENTRANT == 1 ) //重入函数 /*分配一个Newlib C语言程式库 */ struct _reent xNewLib_reent; //_reent静态实例 #endif } tskTCB;
一个双向链表 struct xLIST_ITEM { portTickType xItemValue; //链表节点的值 一个任务延时的节拍数 volatile struct xLIST_ITEM * pxNext; volatile struct xLIST_ITEM * pxPrevious; void * pvOwner; //item所有者 通常是任务控制模块 TCB void * pvContainer; //指向链表节点所在地链表 根据这个指针,就能知道任务是在就 绪任务链表中还是阻塞任务链表中 }; typedef struct xLIST_ITEM xListItem;
struct xMINI_LIST_ITEM { portTickType xItemValue; //值 volatile struct xLIST_ITEM *pxNext; //下一个节点 volatile struct xLIST_ITEM *pxPrevious; //上一个 }; typedef struct xMINI_LIST_ITEM xMiniListItem; //mini
//通用的链表节点 typedef struct xLIST { volatile unsigned portBASE_TYPE uxNumberOfItems; // 链表中有多少元素 volatile xListItem * pxIndex; //用来遍历列表 指向上次访问的节点 volatile xMiniListItem xListEnd; // 链表尾节点 没有链表元素时指向自己 } xList;
队列 typedef struct QueueDefinition { signed char *pcHead; /*< 指向 队列的存储区域开始 */ signed char *pcTail; /*< 指向队列的存储区域的结束字节. 一旦更多的字节被分配要存储的队列项,这是作为一个标记。 */ signed char *pcWriteTo; /*< 指向队列的存储区域下一个空的地方 */ union /* 使用联合编码标准是个例外,以确保两个相互排斥的结构成员不同时出现(浪费RAM)。 */ { signed char *pcReadFrom; /*< 指向最后一个地方that a queued item was read from 当一个结构体被用作队列. */ unsigned portBASE_TYPE uxRecursiveCallCount;/*< Maintains a count of the numebr of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */ } u; xList xTasksWaitingToSend; /*< 任务列被阻塞等待添加到这个队列. Stored in priority order. */ xList xTasksWaitingToReceive; /*< 任务列被阻塞等待读这个队列 Stored in priority order. */ volatile unsigned portBASE_TYPE uxMessagesWaiting;/*< 目前队列中的项目数 */ unsigned portBASE_TYPE uxLength; /*< 队列的长度 defined as the number of items it will hold, */ unsigned portBASE_TYPE uxItemSize; /*< 队列每个项目的大小 */ volatile signed portBASE_TYPE xRxLock; /*< 当队列被锁时存储队列接受到的任务的数量 (removed from the queue) . Set to queueUNLOCKED when the queue is not locked. */ volatile signed portBASE_TYPE xTxLock; /*< 当队列被锁时存储队列传输的任务的数量 (added to the queue). Set to queueUNLOCKED when the queue is not locked. */ #if ( configUSE_TRACE_FACILITY == 1 ) unsigned char ucQueueNumber; unsigned char ucQueueType; #endif #if ( configUSE_QUEUE_SETS == 1 ) struct QueueDefinition *pxQueueSetContainer; #endif } xQUEUE;
相关文章推荐
- 第二人生的源码分析(九十六)LLMenuItemGL实现菜单的显示
- boost::mpl::list 源码分析
- List<T>.Contains(T item)为什么我把两封一样的邮件经分析后一模一样的数据mail_data先后导入进去,第2封信还是会加到mailList里去 ?? 搞不懂..
- 集合框架源码分析三(实现类篇ArrayList,LinkedList,HashMap)
- open-iscsi源码分析 -- list-head分析
- folly源码分析(4)- ConcurrentSkipList.h
- IssueVision的List控件源码分析
- Memcached源码分析之内存管理篇之item结构图及slab结构图
- Beanstalk 源码分析----涉及到的结构体
- Nginx 源码分析-- ngx_array、ngx_list基本数据结构
- FFmpeg 源码分析 Part Two:重要的结构体
- Lighttpd1.4.20源码分析之插件系统(1)---plugin结构体和插件接口
- Android源码分析:HeaderViewListAdapter
- 第二人生的源码分析(九十六)LLMenuItemGL实现菜单的显示
- nginx源码分析—链表结构ngx_list_t
- 第二人生的源码分析(九十六)LLMenuItemGL实现菜单的显示
- nginx源码分析—链表结构ngx_list_t
- Qt学习笔记,再次分析EVA源码之后得出的结论-QListView,QListViewItem(Qt3);Q3ListView,Q3ListViewItem(Qt4)
- View的DrawableState(即StateListDrawable)变化的源码分析
- Lighttpd1.4.20源码分析之插件系统(1)---plugin结构体和插件接口