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:
bernard.xiong 2009-09-18 13:10:14 +00:00
parent 90238948ba
commit 04234d1821
1 changed files with 8 additions and 1 deletions

View File

@ -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