功勋会员
WJ
- 积分
- 6304
- 威望
- 1456
- 贡献
- 4674
- 兑换币
- 17
- 注册时间
- 2008-4-6
- 在线时间
- 87 小时
|
<>官网:http://www.micrium.com</P><P>关于移植RTOS,这里有个经较好的资源网,<A target=_blank href="http://www.xinworks.com/bbs/thread.php?fid-36.html">http://www.xinworks.com/bbs/thread.php?fid-36.html</A></P><P>下面的摘自这个论坛:</P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">移植</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">uC/OS</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">对目标处理器有一定要求</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这个可以参照</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><<uc/OS-II</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">源码公开的实时嵌入式操作系统</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">>></SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">一书中第</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">8</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">章的内容</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">整个嵌入式系统分为两大层</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">:</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">硬件层和软件层</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这里主要研究软件层的架构</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">软件层主要分为四个部分</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">:</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">实时操作系统内核</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">与处理器相关部分</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">与应用相关部分</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">用户的应用系统</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1>l </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">实时操作系统内核</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">实时操作系统对系统资源进行管理。主要包括任务分配和调度、系统时钟服务、内存管理、消息机制、异常处理等等。</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">uC/OS</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">所有系统服务均由内核提供。内核将应用系统和底层硬件结合成一个完整的实时系统。</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">移植的时候内核是不变的</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">开发者根据自己应用系统的需要来选择实时操作系统内核</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">开发者不能对内核随意访问,只能使用内核提供的功能服务来开发自己的应用系统。内核确定,那么所提供的系统管理能力,系统服务也就得到了限定。开发者只能在规定的范围内对系统作些改动</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1>2 </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">与处理器相关的代码</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这是移植中最关键的部分</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">内核将应用系统和底层硬件有机的结合成一个实时系统</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">要使同一个内核能适用于不同的硬件体系</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">就需要在内核和硬件之间有一个中间层</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这就是与处理器相关的代码</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">处理器不同</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这部分代码也不同</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1> </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">我们在移植时需要自己处理这部分代码</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">可以自己编写</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">也可以直接使用已经成功移植的代码</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">. </SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1> </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">uC/OS</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中这一部分代码分成三个文件</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">:OS_CPU.H, OS_CPU_A.ASM, OS_CPU_C.C</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1>1) OS_CPU.H</SPAN><BR><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">包括了用</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">#define</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">定义的与处理器相关的常量</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">宏和类型定义</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">具体来讲有系统数据类型定义</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">栈增长方向定义</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">关中断和开中断定义</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">系统软中断的定义等等</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1>2) OS_CPU_A.ASM</SPAN><BR><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这部分需要对处理器的寄存器进行操作</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">所以必须用汇编语言来编写</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">包括四个子函数</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">:OSStartHighRdy(),OSCtxSw(),OSIntCtxSw(),OSTickISR().</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1>OSStartHighRdy()</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在多任务系统启动函数</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">OSStart()</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中调用</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">完成的功能是</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">:</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">设置系统运行标志位</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">OSRunning = TRUE;</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">将就绪表中最高优先级任务的栈指针</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">Load</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">到</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">SP</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">并强制中断返回</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这样就绪的最高优先级任务就如同从中断里返回到运行态一样</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">使得整个系统得以运转</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1>OSCtxSw()</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在任务级任务切换函数中调用的</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">任务级切换是通过</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">SWI</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">或者</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">TRAP</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">人为制造的中断来实现的</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.ISR</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的向量地址必须指向</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">OSCtxSw().</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这一中断完成的功能</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">:</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">保存任务的环境变量</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">(</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">主要是寄存器的值</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">通过入栈来实现</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">),</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">将当前</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">SP</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">存入任务</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">TCB</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">载入就绪最高优先级任务的</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">SP,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">恢复就绪最高优先级任务的环境变量</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中断返回</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这样就完成了任务级的切换</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1>OSIntCtxSw()</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在退出中断服务函数</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">OSIntExit()</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中调用</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">实现中断级任务切换</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">由于是在中断里调用</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">所以处理器的寄存器入栈工作已经做完</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">就不用作这部分工作了</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">具体完成的任务</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">:</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">调整栈指针</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">(</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">因为调用函数会使任务栈结构与系统任务切换时堆栈标准结构不一致</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">),</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">保存当前任务</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">SP,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">载入就绪最高优先级任务的</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">SP,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">恢复就绪最高优先级任务的环境变量</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中断返回</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这样就完成了中断级任务切换</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1>OSTickISR()</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">系统时钟节拍中断服务函数</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这是一个周期性中断</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">为内核提供时钟节拍</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">频率越高系统负荷越重</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">其周期的大小决定了内核所能给应用系统提供的最小时间间隔服务</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">一般只限于</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">ms</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">级</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">(</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">跟</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">MCU</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">有关</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">),</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">对于要求更加苛刻的任务需要用户自己建立中断来解决</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">该函数具体内容</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">:</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">保存寄存器</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">(</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">如果硬件自动完成就可以省略</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">),</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">调用</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">OSIntEnter(),</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">调用</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">OSTimeTick(),</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">调用</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">OSIntExit(),</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">恢复寄存器</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中断返回</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1>3) OS_CPU_C.C</SPAN><BR><BR><SPAN class=tpccontent1>UC/OS</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中共定义了</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">6</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">个函数在该文件中</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">但是最重要的是</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">OSTaskStkInit().</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">其他都是对系统内核的扩展时用的</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1>OSTaskStkInit()</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">是在用户建立任务时系统内部自己调用的</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">对用户任务的堆栈进行初始化</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">使建立好的进入就绪态任务的堆栈与系统发生中断并且将环境变量保存完毕时的栈结构一致</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这样就可以用中断返回指令使就绪的任务运行起来</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">具体的入栈方式要根据不同</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">mcu</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">而定</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">需要参考用户使用的</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">mcu</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">说明书</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">同时还要考虑</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">mcu</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的栈生成方式</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这需要根据具体问题来分析</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在此不做过多论述</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><BR><SPAN class=tpccontent1>3 </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">与应用相关的代码</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这一部分是用户根据自己的应用系统来定制合适的内核服务功能</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">包括两个文件</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">:OS_CFG.H, INCLUDES.H.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1>OS_CFG.H</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">来配置内核</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">用户根据需要对内核进行定制</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">留下需要的部分</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">去掉不需要的部分</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">设置系统的基本情况</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">比如系统可提供的最大任务数量</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">是否定制邮箱服务</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">是否需要系统提供任务挂起功能</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">是否提供任务优先级动态改变功能等等</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1>INCLUDES.H</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">系统头文件</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">整个实时系统程序所需要的文件</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">包括了内核和用户的头文件</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><BR><SPAN class=tpccontent1>4 </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">用户应用系统</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这是整个实时系统的最高层</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">用户通过利用实时操作系统提供的服务来开发自己的具体程序</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">二</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">. </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">用户应用系统编写的模式</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1>kernel</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">提供给用户一些功能函数</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">使得用户的系统建立更加方便</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">但是</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">kernel</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">内部不会处理用户的工作</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">对于整个系统的具体应用工作还得需要用户自己去考虑</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">如何利用好这些功能服务函数就成为一个比较重要的问题</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1>1. main</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">函数的结构</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1>void main (void)</SPAN><BR><SPAN class=tpccontent1>{</SPAN><BR><SPAN class=tpccontent1> </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">初始化系统的硬件</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">;</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1> OSInit();</SPAN><BR><SPAN class=tpccontent1> </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">任务的建立</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">消息机制的建立</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">;</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1> OSStart();</SPAN><BR><SPAN class=tpccontent1>}</SPAN><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这里需要的是在</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">OSStart()</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">执行之前不得启动中断</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">硬件系统还不能工作</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">必须先让软件系统进入工作状态后才行</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1>2. </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中断的结构</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1>ISR:</SPAN><BR><SPAN class=tpccontent1> {</SPAN><BR><SPAN class=tpccontent1> </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">保存处理器寄存器的值</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">;</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1> </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">调用</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">OSIntEnter();</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1> </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">执行用户的工作</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">;</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1> </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">调用</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">OSIntExit();</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1> </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">恢复处理器寄存器的值</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">;</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1> RTI;</SPAN><BR><SPAN class=tpccontent1> }</SPAN><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">用户的中断形式和以前一样</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">没有什么大的变化</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">仅仅是在原来用户</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">ISR</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的基础上在固定的位置加了两个函数</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">:OSIntEnter(), OSIntExit().</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1>3. </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">各个任务的结构</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><BR><SPAN class=tpccontent1>void YourTask (void)</SPAN><BR><SPAN class=tpccontent1>{</SPAN><BR><SPAN class=tpccontent1>for(;;) </SPAN><BR><SPAN class=tpccontent1>{</SPAN><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">用户代码</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">调用的系统服务</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1>}</SPAN><BR><SPAN class=tpccontent1>}</SPAN><BR></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在任务启动函数执行完后</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">系统会切换到最高优先级的任务去执行</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">此时</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">可以将系统硬件部分的启动放在该任务的最前边</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">仅仅是启动时执行一次</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">主要是启动系统的节拍中断</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">或者一些必须在多任务系统调度后才能初始化的部分</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">使系统的真正开始工作</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">,</SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">达到软件硬件的基本同步</SPAN></SPAN><SPAN class=tpccontent1><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">.</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1>Void HighestPrioTask(void)</SPAN><BR><SPAN class=tpccontent1>{</SPAN><BR><SPAN class=tpccontent1>OSStartHardware();</SPAN><BR><SPAN class=tpccontent1>For (;;)</SPAN><BR><SPAN class=tpccontent1>{</SPAN><BR><SPAN class=tpccontent1> </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">用户代码</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1> </SPAN></SPAN><SPAN class=tpccontent1><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">调用的系统服务</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><BR><SPAN class=tpccontent1>}</SPAN><BR><SPAN class=tpccontent1>}</SPAN></SPAN></P> |
|