UCOS-iii 中断处理

UCOS-iii 的中断处理有两种方式:

1、立即处理中断:当中断发生时,程序的PC指针被赋值中断服务程序ISR,关中断,中断服务程序处理完事件,开中断。中断返回。

2、延迟处理中断:当中断发生时,程序的PC指针被赋值中断服务程序ISR,关中断,在中断处理程序中不直接处理中断源,而是在优先级为0的中断服务任务中登记,并就绪中断服务任务,然后开中断。从中断返回。延迟处理的目的是为了减小关中断的时间。把中断处理任务放在任务级处理,而不是中断级。


;           2)Pseudo-code is:   //伪代码
;              a) Get the process SP, if 0 then skip (goto d) the saving part (first context switch);
;              b) Save remaining regs r4-r11 on process stack;
;              c) Save the process SP in its TCB, OSTCBCurPtr->OSTCBStkPtr = SP;
;              d) Call OSTaskSwHook();
;              e) Get current high priority, OSPrioCur = OSPrioHighRdy;
;              f) Get current ready thread TCB, OSTCBCurPtr = OSTCBHighRdyPtr;
;              g) Get new process SP from TCB, SP = OSTCBHighRdyPtr->OSTCBStkPtr;
;              h) Restore R4-R11 from new process stack;
;              i) Perform exception return which will restore remaining context.
;
;           3) On entry into PendSV handler://进入PendSV 中断处理程序
;              a) The following have been saved on the process stack (by processor):
;                 xPSR, PC, LR, R12, R0-R3
;              b) Processor mode is switched to Handler mode (from Thread mode)
;              c) Stack is Main stack (switched from Process stack)
;              d) OSTCBCurPtr      points to the OS_TCB of the task to suspend

;                 OSTCBHighRdyPtr  points to the OS_TCB of the task to resume

//进入中断处理程序后的状态变化
a)硬件自动保存xPSR ,PC ,LR , R0-R3 寄存器的值。
b)处理器模式切换,从线程模式切换到处理模式。
c)程序栈从进程栈切换到主栈。
d)当前任务被挂起,新任务被执行。

//////////////////////////////////////////////////////////////

进入中断后,PC指针指向中断服务程序,但栈指针的值没变。



猜你喜欢

转载自blog.csdn.net/register_k/article/details/80003308
今日推荐