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指针指向中断服务程序,但栈指针的值没变。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值