- 1、本文档共48页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
* * * * * * * * * * * * * * * * * * * * * * * * 3.3 Function Queue Scheduling模型 void interrupt HandleDeviceA(void) { !! Take care of Device A QueueAppend(functionsQueue, FunctionA); } void interrupt HandleDeviceB(void) { !! Take care of Device B QueueAppend(functionsQueue, FunctionB); } void FunctionA(void) { !! Handle actions required by device A } void FunctionB(void) { !! Handle actions required by device B } Queue functionsQueue; void main(void) { while(TRUE) { while(QueueHasItems(functionsQueue)) !! Call first function on queue !! Remove the function from queue } } 3.3 Function Queue Scheduling模型 【优点】 main函数可以按照任何优先级策略来调用队列中的函数; 高优先级的功能能得到更多的CPU资源; 回想一下round robin with interrupts,每一轮main循环,高优先级的功能只能得到一次执行机会; 与此相对,低优先级的功能将获得更少的CPU资源,甚至有可能饿死。 3.3 Function Queue Scheduling模型 【缺点】 不能抢占。如果某个低优先级的功能执行时间很长的话,一旦这个功能被执行,高优先级的功能就需要等待很长时间才能执行; 编程复杂。 Function queue的简单演示 函数指针演示 Function queue简单演示 函数指针演示 typedef int (*func) (int, int); int add(int a, int b) { return a+b; } int decrease(int a, int b) { return a-b; } 函数指针演示 01 int main(int argc, char *argv[]) 02 { 03 func f[2]; 04 f[0] = add; 05 f[1] = decrease; 06 int c1 = f[0](1,2); 07 printf(1+2=%d\n, c1); 08 int c2 = f[1](1,2); 09 printf(1-2=%d\n, c2); 10 return 1; 11 } Function Queue简单演示 01 #include vector 02 #include iostream 03 using namespace std; 04 typedef int (*func) (int, int); 05 typedef struct CommandTag 06 { 07 func function; 08 int parameter1; 09 int parameter2; 10 }Command; Function Queue简单演示 01 void functionQueueSimpleDemo() 02 { 03 vectorCommand commands; 04 while(1) 05 { 06 Command com; 07 char comType; 08 cout Input command and parameters. endl Command a means add, d means decrease, “ endl e means break the input loop and execure all commands input. endl; 09 cin comType com.parameter1 com.parameter2; 10 if (comType == e) 11 break;
您可能关注的文档
- §2.6冲激响应和阶跃响应.ppt
- 平面连杆机构课案.ppt
- §2.7《闭合电路的欧姆定律》.ppt
- 平面任意力系课案.ppt
- §3、连续型随机变量及其分布.ppt
- 平面图形的几何性质课案.ppt
- 平移的特征课案.ppt
- §3.1多维随机变量的.ppt
- 苹果供应链2课案.ppt
- 破伤风患者的护理课案.ppt
- 3.5.1物体的内能练习教学设计-2023-2024学年浙教版九年级上册科学.docx
- 1.2 原始农业与史前社会 教学设计 2024--2025学年部编版七年级历史上学期.docx
- 油墨市场发展现状调查及供需格局分析预测报告2024-2029版.docx
- 2024至2030年中国微光器件行业深度调研及投资战略分析报告.docx
- 中国增敏化学发光免疫分析仪行业市场现状分析及竞争格局与投资发展研究报告.docx
- 中国普通内圆磨床行业市场现状分析及竞争格局与投资发展研究报告2024-2029版.docx
- 2024至2030年中国高锰酸钾行业深度调研及发展预测报告.docx
- 2024至2030年中国医药行业深度调研及投资战略分析报告.docx
- 2024至2030年中国可再生能源制氢(绿氢)行业深度调研及投资战略分析报告.docx
- 中国男士公文包行业市场现状分析及竞争格局与投资发展研究报告.docx
最近下载
- 音响灯光系统维保方案.docx VIP
- 第五章——陶瓷基复合材料.ppt VIP
- xxxxxxxxxxx工程创“钱江杯”优质工程情况汇报.docx VIP
- 西华大学电气与电子信息学院课程设计—某农村电网110kV变电所继电保护的配置和整定(3).docx
- xx工程创“钱江杯”优质工程情况汇报.doc
- EN 50124-1-2001铁路设施 — 绝缘配合 — 第 1 部分:基本要求 — 所有电气和电子设备的间隙距离和爬电距离(中文版).doc
- 中国古代的法治与教化 教学设计-【新教材】高中历史统编版(2019)选择性必修1.docx
- (高清版)B-T 3836.1-2021 爆炸性环境 第1部分:设备 通用要求.pdf VIP
- 2022《立体仓库控制系统设计》开题报告.doc VIP
- 2024年银行支部书记党课讲稿集合6篇.docx VIP
文档评论(0)