Commit 1a1a209
committed
OS: Fix task switch in task context
The task switch function in task context rt_hw_context_switch
might not be switched due to higher level interrupt happened before
software interrupt to switch context, in the higher level interrupt
if it triggered switch interrupt in interrupt context, the task
context will be messed up.
want to switch TA -> TB : interrupt entered | In TA context now
Interrupt triggered, want to switch to TC | Still in TA context, but it assumed in TB context
software interrupt switch task, task switch TB -> TC, but actually it is still in TA context
so TA's context is actually saved to TB's stack, which is not right.
So we changed task switch here to use interrupt switch flow:
want to switch TA -> TB, interrupt entered | in TA context now
Interrupt triggered, want to switch to TC | still in TA context, but now it will do TA -> TC
software interrupt switch tasl, now do TA -> TC, which is correct now
In this case, it want to do two task switch, A->B, B->C, but accuatually
only 1 task switch is done, A->C due to higher interrupt handler entered before software interrupt,
and in higher interrupt handler, it also triggered task switch
Signed-off-by: Huaqi Fang <[email protected]>1 parent 94996b0 commit 1a1a209
1 file changed
+1
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
126 | | - | |
127 | | - | |
| 125 | + | |
128 | 126 | | |
129 | 127 | | |
130 | 128 | | |
| |||
0 commit comments