- 1、本文档共15页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
freertos co-routine 分析(FreeRTOS co routine 分析)
freertos co-routine 分析(FreeRTOS co routine 分析)
FreeRTOS co routine 分析
Freertos中联合程序 (co routine) 与任务类似, 但在实现上区别,
可参考http: / / / FreeRTOS / taskandcr.html获取详细内容.简单而言联合程序相当于不能抢占的任务,
其优先级均低于任务.因为其非抢占性, 因此其需要的系统资源更少, 不需要独立的堆栈空间.下面将对联合程序进行简单分析.
联合程序控制块
Typedef struct corcoroutinecontrolblock
{
Crcoroutine _ code pxcoroutinefunction 联合程序函数; / * * /
Xlistitem xgenericlistitem; / * 用于把联合程序放到 就绪列表或挂起列表中 * /
Xlistitem xeventlistitem 用于把联合程序放到事件列表中; / * * /
Unsigned portbase _ type uxpriority; / * 联合程序的优先级, 只是相对于其他联合程序而言 * /
Unsigned portbase _ type uxindex 当多个联合程序使用同一个联合函数时作为区分的参数; / * * /
Unsigned portshort uxstate 在联合程序实现的内部需要的一个参数; / * * /
Corcrcb}; / * co routine control block. Note must be identical in size down to uxpriority with tsktcb. * /
可以看出与任务控制块相比, 联合程序的控制块没有保存堆栈相关的信息.其联合程序函数是以函数调用的方式运行,
而不像任务那样把函数地址压入栈中.
联合程序全局变量
The static xlist pxreadycoroutinelists [configmax _ Co _ routine _ priorities]; / * 就绪联合程序 * /
The static xlist xdelayedcoroutinelist1 两个延时队列; / * * /
The static xlist xdelayedcoroutinelist2;
The static xlist * pxdelayedcoroutinelist;
The static xlist * pxoverflowdelayedcoroutinelist;
The static xlist xpendingreadycoroutinelist;
Corcrcb * pxcurrentcoroutine = null;
The static unsigned portbase _ type uxtopcoroutinereadypriority = 0;
The static portticktype xcoroutinetickcount = 0, xlasttickcount = 0, xpassedticks = 0;
联合程序的全局变量使用与任务类似, 均是有一个全局的就绪联合程序数组来保存全部就绪联合程序,
定义了两个延时时使用的列表, 及对应列表的指针, 分别用来指向正在延时的联合程序以及已经超时的联合程序.
联合程序 co routine 的创建
Freertos中创建联合程序是需要传入三个参数, 分别是:
/ *
Pxcoroutinecode 联合程序函数的地址
Uxpriority 联合程序的优先级, 只相对于联合程序有效
Uxindex 用来区分使用同一个联合程序函数的不同联合程序的参数
* /
Signed portbase _ type xcoroutinecreate (crcoroutine _ code pxcoroutinecode, unsigned portbase _ type uxpriority, unsigned portbase _ type uxindex)
{
Signed portbase _ type xreturn;
Corcrcb * pxcoroutine;
/ * allocate the memory that will store the co routine control block. * /
* joint program memory used to control block dynamic allocation.
PxCoRoutine = (corCRCB *) pvPortMalloc (sizeof (cor
您可能关注的文档
- 2009年高考地理热点(专题)试题集锦(Highlights of the 2009 college entrance examination for geographical topics (Topics)).doc
- 2009年自考《马克思主义基本原理概论》复习资料(Review the materials of Marx's basic principles of Marxism in 2009).doc
- 2009年湖北省高考数学试题答案(文数)(In 2009, Hubei province college entrance examination mathematics examination questions answer (text number)).doc
- 2009年税务系统竞争上岗试题附答案-税易网(In 2009 the tax system of competition questions with answers - tax.).doc
- 2009年全国美术高考试题1天津市联考考题 素描正面男老人头像默写(In 2009 the national fine arts college entrance examination exam exam 1 Tianjin sketch positive male Claus head dictation).doc
- 2009年河北100强企业(Hebei top 100 enterprises in 2009).doc
- 2010-2011学年七年级语文下册第一单元测试题(二)人教新课标版(2010-2011 school year seven grade language book first unit (two) taught the new curriculum.).doc
- 2010-2011学年第二学期教研计划(Second semester study plan for the 2010-2011 academic year).doc
- 2010-2011学年八年级物理下学期期中测试题(无答案) 教科版(2010-2011 academic year eight grade physics next semester mid-term test questions (no answer) teaching section).doc
- 2010—2011学年(下)七年级期中考试语文(2010 - 2011 academic year (next) seven grade midterm examination language).doc
最近下载
- 2024年延安职业技术学院高职单招职业技能测验2018-2023年典型考题含答案解析.docx
- 2023年上海第二工业大学网络工程专业《计算机组成原理》科目期末试卷A(有答案).docx VIP
- 2022浙ST19壁挂式轻便消防水龙及室内消火栓安装.pdf
- 《热力学第二定律》练习题及解答.pdf
- 浅析科隆公司成本管理存在的问题及对策.docx VIP
- 小学数学“图形与几何”结构化教学.pptx VIP
- 2025年苏州工业园区服务外包职业学院单招职业适应性测试题库精选.docx VIP
- 企业成本管理存在的问题及对策.docx VIP
- 2025年幼儿园教师职称五套试题及答案 .pdf VIP
- 2024中国营养健康食品行业蓝皮书-CIC灼识咨询.ppt
文档评论(0)