UC/OS-II 的中断

骑猪看日落 2022-07-12 04:26 102阅读 0赞



3.1.1 UC/OS-II 的中断过程

Center

为了记录中断嵌套的层数,UC/OS-II定义了一个全局变量OSIntNesting

两个重要函数OSIntEnter()和OSIntExit()

函数OSIntEnter()的作用就是把全局变量OSIntNesting加1,被用于记录中断嵌套层数。

void OSIntEnter(void)

{

  1. If(OSRunning== TRUE)

{

  1. If(OSIntNesting < 255)
  2. \{
  3. OSIntNesting ++;

}

}

}

函数OSIntEnter()的调用通常发生在中断服务程序保护了被中断任务的断点数据之后,运行用户中断服务代码之前,称为进入中断服务函数。

OSIntExit()的流程图如下:

![Image 1][]

OSIntExit(void)

{

#if OS_CRITICAL_METHOD == 3

OS_CPU­_SR cpu_sr;

#endif

  1. If(OSRunning == TRUE)
  2. \{
  3. OS\_ENTER\_CRITICAL();
  4. If(OSIntNesting > 0)
  5. \{
  6. OSIntNesting --;

}

If((OSIntNesting ==0)&&(OSLockNesting == 0))

{

OSIntExitY =OSUnMapTbl[OSRdyGrp];

OSPrioHighRdy=(INT8U)((OSIntExitY<<3)+OSUnMapTbl[OSRdyTbl[OSIntExitY]]);

If(OSPrioHighRdy != OSPrioCur)

{

  1. OSTCBHighRdy = OSTCBPrioTbl\[OSPrioHigh \]
  2. OSCtxSwCtr++;
  3. OSIntCtxSw();

}

}

OS_EXIT_CRITICAL();

}

}

[Image 1]:

发表评论

表情:
评论列表 (有 0 条评论,102人围观)

还没有评论,来说两句吧...

相关阅读