- 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-2025学年高一上学期1月期末考试政治.docx
- 2025年高三二轮专题复习课件地理(艺体生专用)第1讲宇宙中的地球地球运动规律专题一.pptx
- 湖南省长沙市一中芙蓉中学等校2024-2025学年高一下学期2月开学联考政治试题.docx
- 云南省大理白族自治州高三上学期二模考试历史.docx
- 2024-2025学年高二政治课件(选择性必修1)4-1时代的主题.pptx
- 高考备考资料之数学人教B版全国用课件第二章函数概念与基本初等函数Ⅰ27.pptx
- 2025届河南省驻马店市安阳市部分学校高三下学期3月一模英语试题(原卷版+解析版).docx
- 山东省菏泽市牡丹区第二十一初级中学2024-2025学年九年级下学期开学考试化学试题(原卷版+解析版).docx
- 贵州省贵阳市2024-2025学年九年级上学期期末化学试题(原卷版+解析版).docx
- 湖南省郴州市永兴县2024-2025学年九年级下学期第二次质检历史试题(原卷版+解析版).docx
最近下载
- 南芯产品规格书SC8905.pdf
- 浙江省工程勘察设计大师申报表.doc
- 科学教师教学用书五年级上册 - 义务教育课程标准实验教材.pdf VIP
- A成都轨道交通工程机电系统施工工艺标准(第二版)2018.5.pdf
- (高清版)B-T 18380.36-2022 电缆和光缆在火焰条件下的燃烧试验 第36部分:垂直安装的成束电线电缆火焰垂直蔓延试验 D类.pdf VIP
- 电商平台账单导出流程.docx VIP
- 2024年人教版生物七年级上册《第二单元 多种多样的生物》第三章微生物大单元整体教学设计.docx
- 新版FMEA培训课件【第五版】.pptx
- 固态锂电池试制线生产线建设项目申请可行性研究报告.doc
- 护理工作职责与岗位职责培训课件.pptx
文档评论(0)