这样的话会有一个问题,在OS启动前,就执行了滴答中断,滴答中断里面有很多OS本身的处理,这样不太好。
[C] 纯文本查看 复制代码 SysTick_Handler PROC
EXPORT SysTick_Handler
IMPORT osRtxTick_Handler
PUSH {R0,LR} ; Save EXC_RETURN
BL osRtxTick_Handler ; Call osRtxTick_Handler
POP {R0,LR} ; Restore EXC_RETURN
MRS R12,PSP ; Save PSP to R12
B SVC_Context ; Branch to context handling
ALIGN
ENDP
END
[C] 纯文本查看 复制代码 oid osRtxTick_Handler (void) {
os_thread_t *thread;
OS_Tick_AcknowledgeIRQ();
osRtxInfo.kernel.tick++;
// Process Thread Delays
osRtxThreadDelayTick();
osRtxThreadDispatch(NULL);
// Process Timers
if (osRtxInfo.timer.tick != NULL) {
osRtxInfo.timer.tick();
}
// Check Round Robin timeout
if (osRtxInfo.thread.robin.timeout != 0U) {
thread = osRtxInfo.thread.run.next;
if (thread != osRtxInfo.thread.robin.thread) {
osRtxInfo.thread.robin.thread = thread;
if (thread->delay == 0U) {
// Reset Round Robin
thread->delay = osRtxInfo.thread.robin.timeout;
}
}
if (thread->delay != 0U) {
thread->delay--;
}
if (thread->delay == 0U) {
// Round Robin Timeout
if (osRtxKernelGetState() == osRtxKernelRunning) {
thread = osRtxInfo.thread.ready.thread_list;
if ((thread != NULL) && (thread->priority == osRtxInfo.thread.robin.thread->priority)) {
osRtxThreadListRemove(thread);
osRtxThreadReadyPut(osRtxInfo.thread.robin.thread);
EvrRtxThreadPreempted(osRtxInfo.thread.robin.thread);
osRtxThreadSwitch(thread);
osRtxInfo.thread.robin.thread = thread;
thread->delay = osRtxInfo.thread.robin.timeout;
}
}
}
}
}
|