fix context switch bug because interrupt preemptive occurs during context switch procedure.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@48 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
90238948ba
commit
04234d1821
|
@ -81,6 +81,11 @@ rt_hw_context_switch PROC
|
|||
; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack
|
||||
rt_hw_pend_sv PROC
|
||||
EXPORT rt_hw_pend_sv
|
||||
|
||||
; disable interrupt to protect context switch
|
||||
MRS r2, PRIMASK
|
||||
CPSID I
|
||||
|
||||
; clear rt_thread_switch_interrput_flag to 0
|
||||
LDR r0, =rt_thread_switch_interrput_flag
|
||||
MOV r1, #0x00
|
||||
|
@ -103,6 +108,9 @@ swtich_to_thread
|
|||
LDMFD r1!, {r4 - r11} ; pop r4 - r11 register
|
||||
MSR psp, r1 ; update stack pointer
|
||||
|
||||
; restore interrupt
|
||||
MSR PRIMASK, r2
|
||||
|
||||
ORR lr, lr, #0x04
|
||||
BX lr
|
||||
ENDP
|
||||
|
@ -183,7 +191,6 @@ rt_hw_interrupt_thread_switch PROC
|
|||
|
||||
_no_switch
|
||||
BX lr
|
||||
NOP
|
||||
|
||||
ENDP
|
||||
|
||||
|
|
Loading…
Reference in New Issue