UC/OS-II 的中断
3.1.1 UC/OS-II 的中断过程
为了记录中断嵌套的层数,UC/OS-II定义了一个全局变量OSIntNesting
两个重要函数OSIntEnter()和OSIntExit()
函数OSIntEnter()的作用就是把全局变量OSIntNesting加1,被用于记录中断嵌套层数。
void OSIntEnter(void)
{
If(OSRunning== TRUE)
{
If(OSIntNesting < 255)
\{
OSIntNesting ++;
}
}
}
函数OSIntEnter()的调用通常发生在中断服务程序保护了被中断任务的断点数据之后,运行用户中断服务代码之前,称为进入中断服务函数。
OSIntExit()的流程图如下:
![Image 1][]
OSIntExit(void)
{
#if OS_CRITICAL_METHOD == 3
OS_CPU_SR cpu_sr;
#endif
If(OSRunning == TRUE)
\{
OS\_ENTER\_CRITICAL();
If(OSIntNesting > 0)
\{
OSIntNesting --;
}
If((OSIntNesting ==0)&&(OSLockNesting == 0))
{
OSIntExitY =OSUnMapTbl[OSRdyGrp];
OSPrioHighRdy=(INT8U)((OSIntExitY<<3)+OSUnMapTbl[OSRdyTbl[OSIntExitY]]);
If(OSPrioHighRdy != OSPrioCur)
{
OSTCBHighRdy = OSTCBPrioTbl\[OSPrioHigh \];
OSCtxSwCtr++;
OSIntCtxSw();
}
}
OS_EXIT_CRITICAL();
}
}
[Image 1]:
还没有评论,来说两句吧...