高中生
最后登录1970-1-1
在线时间 小时
注册时间2019-6-10
|
看了下FreeRTOS的源码,有一个疑问:
如果执行PendSVHandler中断处理函数实现任务切换的过程中又来了一个中断ISR1,由于PendSVHandler中断的优先级最低,所以这个中断会被打断,转而执行ISR1,在ISR1结束时又会去执行任务切换,再一次触发PendSVHandler,这样就会出现两个PendSVHandler,程序会怎么处理?丢掉一个吗?还是说执行两遍PendSVHandler?我看了下PendSVHandler函数,里面并没有关中断的操作。
还有一个情况,有两个ISR,一个高优先级的ISR1,一个低优先级的ISR2,首先执行ISR2,过程中来了ISR1,ISR1执行完毕后触发一次PendSVHandler,ISR1退出后转而继续执行之前被打断的ISR2,ISR2执行完毕后又触发一次PendSVHandler,这样有两个PendSVHandler,是丢掉一个还是执行两遍PendSVHandler?
PendSVHandler的源码:
[mw_shl_code=c,true]xPortPendSVHandler:
mrs r0, psp
isb
/* Get the location of the current TCB. */
ldr r3, =pxCurrentTCB
ldr r2, [r3]
/* Is the task using the FPU context? If so, push high vfp registers. */
tst r14, #0x10
it eq
vstmdbeq r0!, {s16-s31}
/* Save the core registers. */
stmdb r0!, {r4-r11, r14}
/* Save the new top of stack into the first member of the TCB. */
str r0, [r2]
stmdb sp!, {r0, r3}
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
msr basepri, r0
dsb
isb
bl vTaskSwitchContext
mov r0, #0
msr basepri, r0
ldmia sp!, {r0, r3}
/* The first item in pxCurrentTCB is the task top of stack. */
ldr r1, [r3]
ldr r0, [r1]
/* Pop the core registers. */
ldmia r0!, {r4-r11, r14}
/* Is the task using the FPU context? If so, pop the high vfp registers
too. */
tst r14, #0x10
it eq
vldmiaeq r0!, {s16-s31}
msr psp, r0
isb
#ifdef WORKAROUND_PMU_CM001 /* XMC4000 specific errata */
#if WORKAROUND_PMU_CM001 == 1
push { r14 }
pop { pc }
#endif
#endif
bx r14[/mw_shl_code]
|
|