PikoRT / pikoRT

A tiny Linux-like real-time kernel optimized for ARM Cortex-M chips
Other
304 stars 61 forks source link

Remove sched_elect in serialchar_callback #29

Closed mlouielu closed 7 years ago

mlouielu commented 7 years ago

DO NOT USE sched_elect inside the irq.

If a context switch is done inside the irq, it will make v7m-head.S pop {pc} to a undefined place, or not able to pop {pc} out.

cc. @yenWu.

iankuan commented 7 years ago

@mlouielu , let me double-check it. You mean that triggering scheduler in irq context would violate flow of exception handler due to exception return ?

If so, you might be right. How about the result of test suites and behavior of minishell?

mlouielu commented 7 years ago

Although I think this is a correct fix, please hold off a second.

I still trying to figure out why we can not do a context switch inside a regular ISR....it is weird.

mlouielu commented 7 years ago

Confirm that this have some bug inside, reproduce step:

mlouielu commented 7 years ago

Currently, I'm working on #36 to ensure that this problem isn't coming from the scheduler.

jserv commented 7 years ago

The use of sched_elect(0) SHOULD be deprecated. Let's introduce new kernel function schedule().

jserv commented 7 years ago

+1 I defer to @yenWu.

iankuan commented 7 years ago

Moreover, PendSV handler is involved with sched_elect(). It's in irq context and works well due to the lowest priority of pendsv. It's always at the bottom of interrupt handle stack and only exception return to Thread mode. It fits the requirements of the scheduler.