初中生
最后登录1970-1-1
在线时间 小时
注册时间2014-10-24
|
这是困扰很久的问题了,求大神解答。在任务级调度函数中OS_TASK_SW()函数是在临界段中执行的,即已经通过将PRIMASK写入1关闭所有可屏蔽的中断。
那么在OS_TASK_SW()中触发的PendSV异常还能够得到响应吗?
虽然知道结果是一定可以响应的,否则任务怎么切换呢。可是不明白为什么中断关闭了还能响应PendSV异常呢???
- <div>OSCtxSw</div><div> LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch)</div><div> LDR R1, =NVIC_PENDSVSET</div><div> STR R1, [R0]</div><div> BX LR</div>
复制代码
- <div>void OS_Sched (void)</div><div>{</div><div>#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */</div><div> OS_CPU_SR cpu_sr = 0;</div><div>#endif</div><div>
- </div><div>
- </div><div>
- </div><div> OS_ENTER_CRITICAL();</div><div> if (OSIntNesting == 0) { /* Schedule only if all ISRs done and ... */</div><div> if (OSLockNesting == 0) { /* ... scheduler is not locked */</div><div> OS_SchedNew();</div><div> if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */</div><div> OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];</div><div>#if OS_TASK_PROFILE_EN > 0</div><div> OSTCBHighRdy->OSTCBCtxSwCtr++; /* Inc. # of context switches to this task */</div><div>#endif</div><div> OSCtxSwCtr++; /* Increment context switch counter */</div><div> OS_TASK_SW(); /* Perform a context switch */</div><div> }</div><div> }</div><div> }</div><div> OS_EXIT_CRITICAL();</div><div>}</div>
复制代码
|
|